Video signal encoding/decoding method and apparatus

ABSTRACT

An image signal decoding method according to the present invention comprises the steps of: decoding information indicating whether a current block is encoded using a multi-mode intra prediction; when it is determined that the current block is encoded in the multi-mode intra prediction, dividing the current block into a plurality of partial blocks; and obtaining an intra prediction mode of each of the plurality of partial blocks.

CROSS REFERENCE TO RELATED APPLICATION(S)

This application is a Divisional Application of U.S. patent applicationSer. No. 17/016,867, filed on Sep. 10, 2020, which is a DivisionalApplication of U.S. patent application Ser. No. 16/097,394, filed onOct. 29, 2018, which is a U.S. National Stage Application ofInternational Application No. PCT/KR2017/004576, filed on Apr. 28, 2017,which claims the benefit under 35 USC 119(a) and 365(b) of Korean PatentApplication No. 10-2016-0052925 filed on Apr. 29, 2016, Korean PatentApplication No. 10-2016-0052692 filed Apr. 29, 2016, Korean PatentApplication No. 10-2017-0050054, filed Apr. 18, 2017 and Korean PatentApplication No. 10-2017-0050049, filed Apr. 18, 2017, in the KoreanIntellectual Property Office.

TECHNICAL FIELD

The present invention relates to a method and an apparatus forencoding/decoding image signal.

BACKGROUND ART

Recently, demands for multimedia data such as video have been rapidlyincreasing on internet. However, developing rate of bandwidths ofchannels is hard to follow the amount of multimedia data that is rapidlyincreasing.

DISCLOSURE Technical Problem

An object of the present invention is to improve compression efficiencyof an image by using a multi-intra-prediction mode in encoding/decodingan image.

An object of the present invention is to improve compression efficiencyof an image by efficiently encoding/decoding a multi-intra-predictionmode of a target encoding/decoding block in encoding/decoding an image.

An object of the present invention is to improve compression efficiencyof an image by efficiently encoding/decoding coefficients in a partialblock.

Technical Solution

A method and an apparatus for decoding an image according to the presentinvention may decode information indicating whether a current block isencoded using a multi-intra-prediction mode; partition the current blockinto a plurality of partial blocks when it is determined that thecurrent block is encoded by the multi-intra-prediction mode; and obtainan intra-prediction mode of each of the plurality of partial blocks.

A method and an apparatus for decoding an image according to the presentinvention may, when partitioning the current block into the plurality ofpartial blocks, determine an inflection point among adjacent pixelsadjacent to the current block; obtain slope information based on aplurality of pixels adjacent to the inflection point; and determine apartitioning shape of the current block based on the inflection pointand the slope information.

In a method and an apparatus for decoding an image according to thepresent invention, the inflection point may be determined based on aninflection value of each of adjacent pixels, and the inflection valuemay be generated based on a differentials value between neighboringpixels neighboring the adjacent pixel.

In a method and an apparatus for decoding an image according to thepresent invention may, when obtaining the intra-prediction mode of eachof the plurality of partial blocks, obtain a first intra-prediction modeof a first partial block; decode a differential value between the firstintra-prediction mode and a second intra-prediction mode of a secondpartial block; and obtain the second intra-prediction mode based on thedifferential value.

In a method and an apparatus for decoding an image according to thepresent invention, the intra-prediction mode of each of the plurality ofpartial blocks may have a different value.

A method and an apparatus for encoding an image according to the presentinvention may determine whether a current block is encoded by amulti-intra-prediction mode; encode information indicating whether thecurrent block uses a multi-intra-prediction mode, based on thedetermination result; when the current block is set to use amulti-intra-prediction mode, partition the current block into aplurality of partial blocks; and determine an intra-prediction mode ofeach of the plurality of partial blocks.

A method and an apparatus for encoding an image according to the presentinvention may, when partitioning the current block into the plurality ofpartial blocks, determine an inflection point among adjacent pixelsadjacent to the current block; obtain slope information based on aplurality of pixels adjacent to the inflection point; and determine apartitioning shape of the current block based on the inflection pointand the slope information.

In a method and an apparatus for encoding an image according to thepresent invention, the inflection point may be determined based on aninflection value of each of adjacent pixels, and the inflection valuemay be generated based on a differentials value between neighboringpixels neighboring the adjacent pixel.

A method and an apparatus for encoding an image according to the presentinvention may determine a first intra-prediction mode of a first partialblock among the plurality of partial blocks; determine a secondintra-prediction mode of a first partial block among the plurality ofpartial blocks; encode a differential value between the firstintra-prediction mode and the second intra-prediction mode.

In a method and an apparatus for encoding an image according to thepresent invention, the intra-prediction mode of each of the plurality ofpartial blocks may have a different value.

Advantageous Effects

According to the present invention, compression efficiency of an imagemay be improved by using a multi-intra-prediction mode inencoding/decoding an image.

According to the present invention, compression efficiency of an imagemay be improved by efficiently encoding/decoding amulti-intra-prediction mode of a target encoding/decoding block inencoding/decoding an image.

According to the present invention, compression efficiency of an imagemay be improved by efficiently encoding/decoding coefficients in apartial block.

DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram illustrating a device for encoding imageaccording to an embodiment of the present invention.

FIG. 2 is a block diagram illustrating a device for decoding an imageaccording to an embodiment of the present invention.

FIG. 3 is a diagram for explaining an intra-prediction method using a DCmode.

FIG. 4 is a diagram for explaining an intra-prediction method using aplanar mode.

FIG. 5 is a diagram for explaining an intra-prediction method using adirectional prediction mode.

FIG. 6 is a diagram illustrating a method for encoding coefficients of atransform block as an embodiment to which the present invention isapplied.

FIG. 7 is a diagram illustrating a method of encoding a maximum value ofa coefficient of a partial block as an embodiment to which the presentinvention is applied.

FIG. 8 is a diagram illustrating a method of encoding a first thresholdvalue flag for a partial block as an embodiment to which the presentinvention is applied.

FIG. 9 is a diagram illustrating a method of decoding coefficients of atransform block as an embodiment to which the present invention isapplied.

FIG. 10 is a diagram illustrating a method of decoding a maximum valueof a coefficient of a partial block as an embodiment to which thepresent invention is applied.

FIG. 11 is a diagram illustrating a method of decoding a first thresholdvalue flag for a partial block as an embodiment to which the presentinvention is applied.

FIG. 12 is a diagram illustrating a method of deriving a first/secondthreshold value flag for a current partial block as an embodiment towhich the present invention is applied.

FIG. 13 is a diagram illustrating a method of determining a size/shapeof a partial block based on a merge flag as an embodiment to which thepresent invention is applied.

FIG. 14 is a diagram illustrating a method of determining a size/shapeof a partial block based on a partitioning flag as an embodiment towhich the present invention is applied.

FIG. 15 is a diagram illustrating a method of determining a size/shapeof a partial block based on partitioning index information as anembodiment to which the present invention is applied.

FIG. 16 is a diagram illustrating a method of partitioning a transformblock based on a position of a non-zero coefficient as an embodiment towhich the present invention is applied.

FIG. 17 is a diagram illustrating a method of selectively partitioning apartial region of a transform block as an embodiment to which thepresent invention is applied.

FIG. 18 is a diagram illustrating a method of partitioning a transformblock based on DC/AC component attribute in a frequency domain as anembodiment to which the present invention is applied.

FIG. 19 is a flowchart illustrating a procedure of determining whetherto use a multi-intra-prediction mode in an encoding procedure.

FIG. 20 is a diagram for explaining an example of searching for aninflection point.

FIG. 21 is a diagram illustrating a partitioning shape according to ashape of a current block.

FIG. 22 is a diagram for explaining an example of calculating slopeinformation of an adjacent pixel.

FIG. 23 is a diagram illustrating an example in which an overlappingregion is generated according to a partitioning shape of a currentblock.

FIG. 24 is a flowchart illustrating a procedure of encoding anintra-prediction mode of a partial block.

FIG. 25 is a flowchart illustrating a method of encoding anintra-prediction mode using MPM candidates.

FIG. 26 is a diagram illustrating determination of an MPM candidate of acurrent block.

FIG. 27 is a flowchart illustrating a method of decoding anintra-prediction mode of a current block.

FIG. 28 is a flowchart illustrating a method of decoding anintra-prediction mode using MPM candidates.

MODE FOR INVENTION

A variety of modifications may be made to the present invention andthere are various embodiments of the present invention, examples ofwhich will now be provided with reference to drawings and described indetail. However, the present invention is not limited thereto, and theexemplary embodiments can be construed as including all modifications,equivalents, or substitutes in a technical concept and a technical scopeof the present invention. The similar reference numerals refer to thesimilar element in described the drawings.

Terms used in the specification. ‘first’, ‘second’, etc. can be used todescribe various components, but the components are not to be construedas being limited to the terms. The terms are only used to differentiateone component from other components. For example, the ‘first’ componentmay be named the ‘second’ component without departing from the scope ofthe present invention, and the ‘second’ component may also be similarlynamed the ‘first’ component. The term ‘and/or’ includes a combination ofa plurality of items or any one of a plurality of terms.

It will be understood that when an element is simply referred to asbeing ‘connected to’ or ‘coupled to’ another element without being‘directly connected to’ or ‘directly coupled to’ another element in thepresent description, it may be ‘directly connected to’ or ‘directlycoupled to’ another element or be connected to or coupled to anotherelement, having the other element intervening therebetween. In contrast,it should be understood that when an element is referred to as being“directly coupled” or “directly connected” to another element, there areno intervening elements present.

The terms used in the present specification are merely used to describeparticular embodiments, and are not intended to limit the presentinvention. An expression used in the singular encompasses the expressionof the plural, unless it has a clearly different meaning in the context.In the present specification, it is to be understood that terms such as“including”, “having”, etc. are intended to indicate the existence ofthe features, numbers, steps, actions, elements, parts, or combinationsthereof disclosed in the specification, and are not intended to precludethe possibility that one or more other features, numbers, steps,actions, elements, parts, or combinations thereof may exist or may beadded.

Hereinafter, preferred embodiments of the present invention will bedescribed in detail with reference to the accompanying drawings.Hereinafter, the same constituent elements in the drawings are denotedby the same reference numerals, and a repeated description of the sameelements will be omitted.

FIG. 1 is a block diagram illustrating a device for encoding imageaccording to an embodiment of the present invention.

Referring to 1, an image encoding device 100 may include a picturepartitioning module 110, prediction modules 120 and 125, a transformmodule 130, a quantization module 135, a rearrangement module 160, anentropy encoding module 165, an inverse quantization module 140, aninverse transform module 145, a filter module 150, and a memory 155.

The constitutional parts shown in FIG. 1 are independently shown so asto represent characteristic functions different from each other in theimage encoding device, and it does not mean that each constitutionalpart is constituted in a constitutional unit of separated hardware orsoftware. In other words, each constitutional part includes each ofenumerated constitutional parts for convenience, and at least twoconstitutional parts of each constitutional part may be combined to formone constitutional part or one constitutional part may be divided into aplurality of constitutional parts to perform each function. Theembodiment where each constitutional part is combined and the embodimentwhere one constitutional part is divided are also included in the scopeof the present invention, if not departing from the essence of thepresent invention.

Also, some of constituents may not be indispensable constituentsperforming essential functions of the present invention but be optionalconstituents improving only performance thereof. The present inventionmay be implemented by including only the indispensable constitutionalparts for implementing the essence of the present invention except theconstituents used in improving performance. The structure including onlythe indispensable constituents except the optional constituents used inimproving only performance is also included in the scope of the presentinvention.

The picture partitioning module 110 may partition an input picture intoat least one block. Here, a block may mean a coding unit (CU), aprediction unit (PU), or a transform unit (TU). The partitioning may beperformed based on at least one of a quad tree or a binary tree. A quadtree is a method of partitioning an upper-level block into fourlower-level blocks whose width and height are half of the upper-levelblock. A binary tree is a method of partitioning an upper-level blockinto two lower-level blocks whose width or height is half of theupper-level block. Using the binary tree-based partitioning, a block mayhave a square shape as well as a non-square shape.

Hereinafter, in embodiments of the present invention, a coding unit maybe used as a unit for performing encoding, or may be used as a unit forperforming decoding.

The prediction modules 120 and 125 may include an inter-predictionmodule 120 for performing inter-prediction and an intra-predictionmodule 125 for performing intra-prediction. Whether to performinter-prediction or intra-prediction for a prediction unit may bedetermined, and specific information (e.g., intra-prediction mode,motion vector, reference picture, etc.) according to each predictionmethod may be determined. Here, a processing unit subjected toprediction may be different from a processing unit for which aprediction method and specific contents are determined. For example, aprediction method, a prediction mode and the like may be determined inunits of prediction unit, and a prediction may be performed in units oftransform unit.

The encoding device may determine an optimal prediction mode for anencoding block by using various schemes such as rate-distortionoptimization (RDO) for a residual block obtained by subtracting a sourceblock from a prediction block. In one example, RDO may be determined bythe following Equation 1.

J(Φ,λ)=D(Φ)+λR(Φ)  [Equation 1]

In the above Equation (1), D represents a deterioration due toquantization, R represents a rate of compressed stream, and J representsthe RD cost. Further, Φ represents an encoding mode, λ represents aLagrangian multiplier. λ may be used as a scale correction coefficientfor matching a unit of error amount and bit amount. In an encodingprocedure, an encoding device may determine a mode with a minimum RDcost value as an optimal mode for an encoding block. Here, an RD-costvalue is calculated considering both a bit rate and an error.

Among intra-prediction modes, a DC mode, which is a non-directionalprediction mode (or a non-angular prediction mode), may use an averagevalue of neighboring pixels of a current block. FIG. 3 is a diagram forexplaining an intra-prediction method using a DC mode.

After an average value of neighboring pixels is filled in a predictionblock, a filtering may be performed on pixels located at a boundary ofthe prediction block. In one example, weighted sum filtering withneighboring reference pixels may be applied to pixels located at a leftor top boundary of a prediction block. For example, Equation 2 shows anexample of generating prediction pixels through a DC mode for eachregion. In Equation 1, zones R1, R2, R3 are regions located at anoutermost (i.e., boundary) of a prediction block, and weighted sumfiltering may be applied to pixels included in the region.

$\begin{matrix}{\mspace{79mu}{{{DC}\mspace{14mu}{value}} = \frac{\begin{matrix}{{\sum_{x = 0}^{{Wid} - 1}{{R\lbrack x\rbrack}\lbrack {- 1} \rbrack}} +} \\  {{\sum_{y = 0}^{{Hei} - 1}{{R\lbrack {- 1} \rbrack}\lbrack y\rbrack}} + {( ( {{Wid} + {Hei}} ) 1}} ) )\end{matrix}}{( {{Wid} + {Hei}} )}}} & \lbrack {{Equation}\mspace{14mu} 2} \rbrack \\{{{{ {R\; 1\mspace{14mu}{region}} )\mspace{14mu}{{{Pred}\lbrack 0\rbrack}\lbrack 0\rbrack}} = ( {{{R\lbrack {- 1} \rbrack}\lbrack 0\rbrack} + {2*{DC}\mspace{14mu}{value}} + {{R\lbrack 0\rbrack}\lbrack {- 1} \rbrack} + 2} )}}2} & \; \\{{{{{ {R\; 2\mspace{14mu}{region}} )\mspace{14mu}{{{Pred}\lbrack x\rbrack}\lbrack 0\rbrack}} = ( {{{R\lbrack x\rbrack}\lbrack {- 1} \rbrack} + {3*{DC}\mspace{14mu}{value}} + 2} )}}2},{x > 0}} & \; \\{{{{{ {R\; 3\mspace{14mu}{region}} )\mspace{14mu}{{{Pred}\lbrack 0\rbrack}\lbrack y\rbrack}} = ( {{{R\lbrack 0\rbrack}\lbrack y\rbrack} + {3*{DC}\mspace{14mu}{value}} + 2} )}}2},{y > 0}} & \; \\{{{ \mspace{79mu}{R\; 4\mspace{14mu}{region}} )\mspace{14mu}{{{Pred}\lbrack x\rbrack}\lbrack y\rbrack}} = {{DC}\mspace{14mu}{value}}},{x > 0},{y > 0}} & \;\end{matrix}$

In the Equation 2, Wid represents a horizontal length of a predictionblock, and Hei represents a vertical length of a prediction block. x, ymeans a coordinate position of each prediction pixel when a most lefttop position of a prediction block is defined as (0, 0). R denotes aneighboring pixel. For example, when pixel s shown in FIG. 3 is definedas R [−1] [−1], pixel a to pixel i may be represented as R [0] [−1] to R[8] [−1], pixel j to pixel r may be represented as R [−1] [0] to R [−1][8]. In the example shown in FIG. 3, a prediction pixel value Pred maybe calculated for each of regions R1 to R4 according to a weighted sumfiltering method as shown in Equation 2.

A planar mode among a non-directional mode is a method of generating aprediction pixel of a current block by applying linear interpolation toneighboring pixels of the current block by distance. For example, FIG. 4is a diagram for explaining an intra-prediction method using a planarmode.

For example, it is assumed that Pred shown in FIG. 4 is predicted in an8×8 encoding block. In this case, pixel e located at a top side of Predand pixel r pixel located at a left bottom side of Pred may be copied toa most bottom side of Pred, and a vertical prediction value may beobtained by linear interpolation by distance in a vertical direction. Inaddition, pixel n located at a left side of Pred and pixel i located ata right top side of Pred may be copied to a most right side of Pred, anda horizontal prediction value may be obtained by linear interpolation bydistance in a horizontal direction. Then, an average value of thehorizontal and vertical prediction values may be determined as a valueof Pred. Equation 3 is a formula expressing a process of obtaining aprediction value Pred according to a planner mode.

$\begin{matrix}{{{{Pred}\lbrack x\rbrack}\lbrack y\rbrack} = \frac{\begin{matrix}{\lbrack {( {{Wid} - {1x}} )*{{R\lbrack {- 1} \rbrack}\lbrack y\rbrack}} \rbrack + \lbrack {( {x + 1} )*{{R\lbrack{Wtd}\rbrack}\lbrack {- 1} \rbrack}} \rbrack +} \\{\lbrack {( {{Hei1} - y} )*{{R\lbrack x\rbrack}\lbrack {- 1} \rbrack}} \rbrack + \lbrack {( {y - 1} )*{{R\lbrack {- 1} \rbrack}\lbrack{Hei}\rbrack}} \rbrack + 1}\end{matrix}}{2}} & \lbrack {{Equation}\mspace{14mu} 3} \rbrack\end{matrix}$

In the Equation 3, Wid represents a horizontal length of a predictionblock, and Hei represents a vertical length of a prediction block. x, ymeans a coordinate position of each prediction pixel when a most lefttop position of a prediction block is defined as (0, 0). R denotes aneighboring pixel. For example, when pixel s shown in FIG. 4 is definedas R [−1] [−1], pixel a to pixel i may be represented as R [0] [−1] to R[8] [−1], pixel j to pixel r may be represented as R [−1] [0] to R [−1][8].

FIG. 5 is a diagram for explaining an intra-prediction method using adirectional prediction mode.

A directional prediction mode (or an angular prediction mode) is amethod of generating at least one or more pixels located in any one of Npredetermined directions among neighboring pixels of a current block asprediction samples.

A directional prediction mode may include a horizontal direction modeand a vertical direction mode. Here, a horizontal directional mode meansmodes having greater horizontal directionality than an angularprediction mode directed to 45 degrees to a left top side, and avertical directional mode means modes having greater vertical directionthan an angular prediction mode directed to 45 degrees to a left topside. A directional prediction mode having a prediction directiondirected to 45 degrees to a left top side may be treated as a horizontaldirectional mode or may be treated as a vertical directional mode. InFIG. 5, horizontal directional modes and vertical directional modes areshown.

Referring to FIG. 5, there may be a direction that does not match to aninteger pixel portion for each direction. In such a case, after applyingan interpolation by distance such as a linear interpolation method, aDCT-IF method, a cubic convolution interpolation method, and the like toa distance between a pixel and a neighboring pixel, and the pixel valuesmay be filled in a pixel position matching to a direction of aprediction block.

A residual value (residual block or transform block) between thegenerated prediction block and an original block may be input to thetransform module 130. A residual block is a minimum unit for transformand quantization procedure. A partitioning method of an encoding blockmay be applied to a transform block. In one example, a transform blockmay be partitioned into four or two partial blocks.

Prediction mode information, motion vector information and the like usedfor prediction may be encoded with a residual value by the entropyencoding module 165 and may be transmitted to a decoding device. When aparticular encoding mode is used, it is possible to transmit to adecoding device by encoding the original block as it is withoutgenerating the prediction block through the prediction modules 120 and125.

The inter-prediction module 120 may predict the prediction unit based oninformation of at least one of a previous picture or a subsequentpicture of the current picture, or may predict the prediction unit basedon information of some encoded regions in the current picture, in somecases. The inter-prediction module 120 may include a reference pictureinterpolation module, a motion prediction module, and a motioncompensation module.

The reference picture interpolation module may receive reference pictureinformation from the memory 155 and may generate pixel information of aninteger pixel or less than the integer pixel from the reference picture.In the case of luma pixels, an 8-tap DCT-based interpolation filterhaving different filter coefficients may be used to generate pixelinformation of an integer pixel or less than an integer pixel in unitsof a ¼ pixel. In the case of chroma signals, a 4-tap DCT-basedinterpolation filter having different filter coefficient may be used togenerate pixel information of an integer pixel or less than an integerpixel in units of a ⅛ pixel.

The motion prediction module may perform motion prediction based on areference picture interpolated by the reference picture interpolationmodule. As methods for calculating a motion vector, various methods,such as a full search-based block matching algorithm (FBMA), a threestep search (TSS), a new three-step search algorithm (NTS), etc., may beused. The motion vector may have a motion vector value in units of a ½pixel or a ¼ pixel based on an interpolated pixel. The motion predictionmodule may predict a current prediction unit by changing the motionprediction method. As motion prediction methods, various methods, suchas a skip method, a merge method, an Advanced Motion Vector Prediction(AMVP) method, etc., may be used.

An encoding device may generate motion information of a current blockbased on motion estimation or motion information of a neighboring block.Here, the motion information may include at least one of a motionvector, a reference image index and a prediction direction.

The intra prediction module 125 may generate a prediction unit based onreference pixel information neighboring to a current block which ispixel information in the current picture. When the neighboring block ofthe current prediction unit is a block subjected to inter-prediction andthus a reference pixel is a pixel subjected to inter-prediction, thereference pixel included in the block subjected to inter-prediction maybe replaced with reference pixel information of a neighboring blocksubjected to intra-prediction. That is, when a reference pixel is notavailable, at least one reference pixel of available reference pixelsmay be used instead of unavailable reference pixel information.

Prediction modes in intra-prediction may include a directionalprediction mode using reference pixel information depending on aprediction direction and a non-directional prediction mode not usingdirectional information in performing prediction. A mode for predictingluma information may be different from a mode for predicting chromainformation, and in order to predict the chroma information,intra-prediction mode information used to predict luma information orpredicted luma signal information may be utilized.

In the intra-prediction method, a prediction block may be generatedafter applying an Adaptive Intra Smoothing (AIS) filter to a referencepixel depending on the prediction modes. The type of the AIS filterapplied to the reference pixel may vary. In order to perform the intraprediction method, an intra prediction mode of the current predictionunit may be predicted from the intra prediction mode of the predictionunit neighboring to the current prediction unit. In prediction of theprediction mode of the current prediction unit by using mode informationpredicted from the neighboring prediction unit, when the intraprediction mode of the current prediction unit is the same as the intraprediction mode of the neighboring prediction unit, informationindicating that the prediction modes of the current prediction unit andthe neighboring prediction unit are equal to each other may betransmitted using predetermined flag information, and when theprediction mode of the current prediction unit is different from theprediction mode of the neighboring prediction unit, entropy encoding maybe performed to encode prediction mode information of the current block.

Also, a residual block including information on a residual value whichis a difference between the prediction unit subjected to prediction andthe original block of the prediction unit may be generated based onprediction units generated by the prediction modules 120 and 125. Thegenerated residual block may be input to the transform module 130.

The transform module 130 may transform the residual block includingresidual data using a transform method, such as discrete cosinetransform (DCT), discrete sine transform (DST), and Karhunen LoeveTransform (KLT). In order to make easy use of a transform method, amatrix operation is performed using a basis vector. Here, depending on aprediction mode in which a prediction block is encoded, varioustransform methods may be variously mixed and used in matrix operation.For example, when performing intra-prediction, depending onintra-prediction mode, discrete cosine transform may be used forhorizontal direction and discrete sine transform may be used forvertical direction.

The quantization module 135 may quantize values transformed to afrequency domain by the transform module 130. That is, the quantizationmodule 135 may quantize transform coefficients of a transform blockgenerated from the transform module 130, and generate a quantizedtransform block having the quantized transform coefficients. Here, thequantization methods may include Dead Zone Uniform ThresholdQuantization (DZUTQ) or a Quantization Weighted Matrix, and the like. Itis also possible to use improved quantization methods that improve thesequantization methods. The quantization coefficients may vary dependingon a block or an importance of an image. Values calculated by thequantization module 135 may be provided to the inverse quantizationmodule 140 and the rearrangement module 160.

The transform module unit 130 and/or the quantization module 135 may beselectively included in the image encoding device 100. That is, theimage encoding device 100 may perform at least one of transformation orquantization on the residual data of the residual block, or may skipboth the transformation and the quantization, thereby encoding theresidual block. A block provided as an input of the entropy encodingmodule 165 is generally referred to as a transform block (or quantizedtransform block) even though either the transformation or thequantization is not performed or both the transformation and thequantization are not performed in the image encoding device 100.

The rearrangement module 160 may rearrange coefficients of quantizedresidual values.

The rearrangement module 160 may change a coefficient in the form of atwo-dimensional block into a coefficient in the form of aone-dimensional vector through a coefficient scanning method. Forexample, the rearrangement module 160 may scan from a DC coefficient toa coefficient in a high frequency domain using a predetermined scanningmethod so as to change the coefficients to be in the form ofone-dimensional vectors.

The entropy encoding module 165 may perform entropy encoding based onthe values calculated by the rearrangement module 160. Entropy encodingmay use various encoding methods, for example, exponential Golombcoding, context-adaptive variable length coding (CAVLC), andcontext-adaptive binary arithmetic coding (CABAC).

The entropy encoding module 165 may encode various information, such asresidual value coefficient information and block type information of thecoding unit, prediction mode information, partition unit information,prediction unit information and transmit unit information, motion vectorinformation, reference frame information, interpolation information of ablock, filtering information, etc. from the rearrangement module 160 andthe prediction modules 120 and 125. In the entropy encoding module 165,the coefficient of the transform block may be encoded, in units ofpartial block in a transform block, as a non-zero coefficient, acoefficient whose absolute value is larger than 1 or 2, and varioustypes of flags indicating a sign of a coefficient, etc. The coefficientthat is not encoded with only the flag may be encoded through theabsolute value of the difference between the coefficient encoded throughthe flag and the coefficient of the actual transform block. A method ofencoding coefficients of the transform block will be described in detailwith reference to FIG. 6.

The entropy encoding module 165 may entropy encode coefficients of thecoding unit input from the rearrangement module 160.

The inverse quantization module 140 may inversely quantize the valuesquantized by the quantization module 135 and the inverse transformmodule 145 may inversely transform the values transformed by thetransform module 130.

In addition, the inverse quantization module 140 and the inversetransform module 145 may perform inverse quantization and inversetransformation by inversely using the quantization method and thetransformation method used in the quantization module 135 and thetransform module 130. In addition, when the transform module 130 and thequantization module 135 perform only quantization and do not perform thetransformation, only the inverse quantization is performed and theinverse transformation may not be performed. When both thetransformation and the quantization are not performed, the inversequantization module 140 and the inverse transform module 145 may neitherperform inverse transform nor inverse quantization nor be included inthe image encoding device 100 and may be omitted.

The residual value generated by the inverse quantization module 140 andthe inverse transform module 145 may be combined with the predictionunit predicted by a motion estimation module, a motion compensationmodule, and the intra-prediction module included in the predictionmodules 120 and 125 so as to generate a reconstructed block.

The filter module 150 may include at least one of a deblocking filter,an offset correction unit, and an adaptive loop filter (ALF).

The deblocking filter may remove block distortion that occurs due toboundaries between the blocks in the reconstructed picture. In order todetermine whether to perform deblocking, the pixels included in severalrows or columns included in the block may be a basis of determiningwhether to apply the deblocking filter to the current block. When thedeblocking filter is applied to the block, a strong filter or a weakfilter may be applied depending on required deblocking filteringstrength. Also, in applying the deblocking filter, horizontal directionfiltering and vertical direction filtering may be processed in parallel.

The offset correction module may correct offset with the originalpicture in units of a pixel in the picture subjected to deblocking. Inorder to perform the offset correction on a particular picture, it ispossible to use a method of applying offset in consideration of edgeinformation of each pixel or a method of partitioning pixels of apicture into the predetermined number of regions, determining a regionto be subjected to perform offset, and applying the offset to thedetermined region.

Adaptive loop filtering (ALF) may be performed based on the valueobtained by comparing the filtered reconstructed picture and theoriginal picture. The pixels included in the picture may be divided intopredetermined groups, a filter to be applied to each of the groups maybe determined, and filtering may be individually performed for eachgroup. Information on whether to apply ALF and a luma signal may betransmitted by coding units (CU), and the shape and filter coefficientof a filter for ALF may vary depending on each block. Also, the filterfor ALF in the same shape (fixed shape) may be applied regardless ofcharacteristics of the application target block.

The memory 155 may store the reconstructed block or picture calculatedthrough the filter module 150, and the stored reconstructed block orpicture may be provided to the prediction modules 120 and 125 inperforming inter-prediction.

FIG. 2 is a block diagram illustrating a device for decoding an imageaccording to an embodiment of the present invention.

Referring to FIG. 2, the image decoding device 200 may include anentropy decoding module 210, a rearrangement module 215, an inversequantization module 220, an inverse transform module 225, predictionmodules 230 and 235, a filter module 240, and a memory 245.

When an image bitstream is input from the image encoding device, theinput bitstream may be decoded according to an inverse process of theimage encoding device.

The entropy decoding module 210 may perform entropy decoding accordingto an inverse process of entropy encoding by the entropy encoding moduleof the image encoding device. For example, corresponding to the methodsperformed by the image encoding device, various methods, such asexponential Golomb coding, context-adaptive variable length coding(CAVLC), and context-adaptive binary arithmetic coding (CABAC) may beapplied. In the entropy decoding module 210, the coefficient of thetransform block may be decoded, in units of partial block in a transformblock, based on a non-zero coefficient, a coefficient whose absolutevalue is larger than 1 or 2, and various types of flags indicating asign of a coefficient, etc. The coefficient that is not represented byonly the flag may be decoded through combination of coefficientrepresented by the flag and coefficient that is signaled. A method ofdecoding the coefficients of the transform block will be described indetail with reference to FIG. 9.

The entropy decoding module 210 may decode information onintra-prediction and inter-prediction performed by the image encodingdevice.

The rearrangement module 215 may perform rearrangement on the bitstreamentropy decoded by the entropy decoding module 210 based on therearrangement method used in the image encoding device. Therearrangement may include reconstructing and rearranging thecoefficients in the form of one-dimensional vectors to the coefficientin the form of two-dimensional blocks. The rearrangement module 215 mayreceive information related to coefficient scanning performed in theimage encoding device and may perform rearrangement via a method ofinversely scanning the coefficients based on the scanning orderperformed in the image encoding device.

The inverse quantization module 220 may perform inverse quantizationbased on a quantization parameter received from the image encodingdevice and the rearranged coefficients of the block.

The inverse transform module 225 may perform the inverse transform ofthe inverse quantized transform coefficients according to apredetermined transform method. Here, the transform method may bedetermined based on a prediction method (inter/intra-prediction), asize/shape of a block, information on intra-prediction mode, etc.

The prediction modules 230 and 235 may generate a prediction block basedon information on prediction block generation received from the entropydecoding module 210 and previously decoded block or picture informationreceived from the memory 245.

The prediction modules 230 and 235 may include a prediction unitdetermination module, an inter-prediction module, and anintra-prediction module. The prediction unit determination module mayreceive various information, such as prediction unit information,prediction mode information of an intra-prediction method, informationon motion prediction of an inter-prediction method, etc. from theentropy decoding module 210, may divide a current coding unit intoprediction units, and may determine whether inter-prediction orintra-prediction is performed on the prediction unit. By usinginformation required in inter-prediction of the current prediction unitreceived from the image encoding device, the inter-prediction module 230may perform inter-prediction on the current prediction unit based oninformation of at least one of a previous picture or a subsequentpicture of the current picture including the current prediction unit.Alternatively, inter-prediction may be performed based on information ofsome pre-reconstructed regions in the current picture including thecurrent prediction unit.

In order to perform inter-prediction, it may be determined for thecoding unit which of a skip mode, a merge mode, an AMVP mode, and aninter block copy mode is used as the motion prediction method of theprediction unit included in the coding unit.

The intra-prediction module 235 may generate a prediction block based onpixel information in the current picture. When the prediction unit is aprediction unit subjected to intra-prediction, intra-prediction may beperformed based on intra-prediction mode information of the predictionunit received from the image encoding device. The intra-predictionmodule 235 may include an adaptive intra smoothing (AIS) filter, areference pixel interpolation module, a DC filter. The AIS filterperforms filtering on the reference pixel of the current block, andwhether to apply the filter may be determined depending on theprediction mode of the current prediction unit. AIS filtering may beperformed on the reference pixel of the current block by using theprediction mode of the prediction unit and AIS filter informationreceived from the image encoding device. When the prediction mode of thecurrent block is a mode where AIS filtering is not performed, the AISfilter may not be applied.

When the prediction mode of the prediction unit is a prediction mode inwhich intra-prediction is performed based on the pixel value obtained byinterpolating the reference pixel, the reference pixel interpolationmodule may interpolate the reference pixel to generate the referencepixel of an integer pixel or less than an integer pixel. When theprediction mode of the current prediction unit is a prediction mode inwhich a prediction block is generated without interpolation thereference pixel, the reference pixel may not be interpolated. The DCfilter may generate a prediction block through filtering when theprediction mode of the current block is a DC mode.

The reconstructed block or picture may be provided to the filter module240. The filter module 240 may include the deblocking filter, the offsetcorrection module, the ALF.

Information on whether or not the deblocking filter is applied to thecorresponding block or picture and information on which of a strongfilter and a weak filter is applied when the deblocking filter isapplied may be received from the image encoding device. The deblockingfilter of the image decoding device may receive information on thedeblocking filter from the image encoding device, and may performdeblocking filtering on the corresponding block.

The offset correction module may perform offset correction on thereconstructed picture based on the type of offset correction and offsetvalue information applied to a picture in performing encoding.

The ALF may be applied to the coding unit based on information onwhether to apply the ALF, ALF coefficient information, etc. receivedfrom the image encoding device. The ALF information may be provided asbeing included in a particular parameter set.

The memory 245 may store the reconstructed picture or block for use as areference picture or block, and may provide the reconstructed picture toan output module.

FIG. 6 is a diagram illustrating a method for encoding coefficients of atransform block as an embodiment to which the present invention isapplied.

A coefficient of a transform block may be encoded in units of apredetermined block (hereinafter, referred to as a partial block) in animage encoding device. A transform block may include one or more partialblocks. A partial block may be a block of N×M size. Here, N and M arenatural numbers, and N and M may be equal to or different from eachother. That is, a partial block may be a square or a non-square block. Asize/shape of a partial block may be fixed (e.g., 4×4) predefined in animage encoding device, or may be variably determined depending on asize/shape of a transform block. Alternatively, an image encoding devicemay determine an optimal size/shape of a partial block in considerationof an encoding efficiency, and encode the partial block. Information ona size/shape of an encoded partial block may be signaled in a level ofat least one of a sequence, a picture, a slice or a block.

An order of encoding partial blocks included in a transform block may bedetermined according to a predetermined scan type (hereinafter, referredto as a first scan type) in an image encoding device. In addition, anorder of encoding coefficients included in a partial block may bedetermined according to a predetermined scan type (hereinafter, referredto as a second scan type). The first scan type and the second scan typemay be the same or different. For the first/second scan type, a diagonalscan, a vertical scan, or a horizontal scan and the like may be used.However, the present invention is not limited thereto, and one or morescan types having predetermined angles may be further added. Thefirst/second scan type may be determined based on at least one of codingblock related information (e.g., maximum/minimum size, partitioningtechnique, etc.), size/shape of transform block, size/shape of partialblock, prediction mode, intra-prediction related information (e.g., avalue of intra-prediction mode, directionality, angle, etc.) orinter-prediction related information.

An image encoding device may encode, in a transform block, positioninformation of a coefficient (hereinafter, referred to as a non-zerocoefficient) having non-zero value first appeared in the above-describedencoding order. Encoding may be performed sequentially from a partialblock including the non-zero coefficient. Hereinafter, referring to FIG.6, a procedure of encoding coefficients of a partial block will bedescribed.

A partial block flag for a current partial block may be encoded (S600).The partial block flag may be encoded in units of a partial block. Thepartial block flag may indicate whether there is at least one non-zerocoefficient in the current partial block. For example, when the partialblock flag is a first value, it may indicate that the current partialblock includes at least one non-zero coefficient, and when the partialblock flag is a second value, it may indicate that all coefficients ofthe current partial block are 0.

A partial block coefficient flag for a current partial block may beencoded (S610). The partial block coefficient flag may be encoded inunits of a coefficient. The partial block coefficient flag may indicatewhether a coefficient is a non-zero coefficient. For example, when thecoefficient is a non-zero coefficient, the partial block coefficientflag may be encoded to a first value, and when the coefficient is zero,the partial block coefficient flag may be encoded to a second value. Thepartial block coefficient flag may be selectively encoded according tothe partial block flag. For example, a current partial block may beencoded for each coefficient of a partial block only when there is atleast one non-zero coefficient present in the current partial block(i.e., the partial block flag is a first value).

A flag (hereinafter, referred to as a first flag) indicating whether anabsolute value of a coefficient is greater than 1 may be encoded (S620).The first flag may be selectively encoded according to a value of thepartial block coefficient flag. For example, when the coefficient is anon-zero coefficient (i.e., the partial block coefficient flag is afirst value), the first flag may be encoded by checking whether anabsolute value of the coefficient is greater than 1. When the absolutevalue of the coefficient is greater than 1, the first flag is encoded toa first value, and when the absolute value of the coefficient is notgreater than 1, the first flag may be encoded to a second value.

A flag (hereinafter, referred to as a second flag) indicating whether anabsolute value of a coefficient is greater than 2 may be encoded (S630).The second flag may be selectively encoded according to a value of thefirst flag. For example, when the coefficient is greaterthan 1 (i.e.,the first flag is a first value), the second flag may be encoded bychecking whether an absolute value of the coefficient is greater than 2.When the absolute value of the coefficient is greater than 2, the secondflag is encoded to a first value, and when the absolute value of thecoefficient is not greater than 2, the second flag may be encoded to asecond value.

The number of at least one of the first flag or the second flag may beat least one to at most N*M. Alternatively, at least one of the firstflag or the second flag may be a fixed number (e.g., one, two, or more)predefined in an image encoding device. The number of the first/secondflag may be different depending on a bit depth of an input image, adynamic range of an original pixel value in a certain region of animage, a block size/depth, a partitioning technique (e.g., quad tree,binary tree), a transforming technique (e.g., DCT, DST), whether to skiptransform, quantization parameters, prediction mode (e.g., intra/intermode), and so on. In addition to the first/second flag, an n-th flagindicating whether an absolute value of a coefficient is greater than nmay be additionally encoded. Here, n may mean a natural number greaterthan two. The number of the n-th flag may be one, two, or more, and maybe determined in the same/similar manner as the first/second flagdescribed above.

Remaining coefficients that are not encoded based on the first/secondflag may be encoded in a current partial block (S640). Here, theencoding may be a procedure of encoding the coefficient value itself.The remaining coefficients may be equal to or greater than two. Theremaining coefficient may be encoded based on at least one of a partialblock coefficient flag, a first flag or a second flag for the remainingcoefficient. For example, the remaining coefficient may be encoded to avalue obtained by subtracting (partial block coefficient flag+firstflag+second flag) from an absolute value of the remaining coefficient.

A sign for a coefficient of a partial block may be encoded (S650). Thesign may be encoded in a flag format in units of a coefficient. The signmay be selectively encoded according to a value of the partial blockcoefficient flag described above. For example, the sign may be encodedonly when the coefficient is a non-zero coefficient (i.e., the partialblock coefficient flag is a first value).

As described above, each of absolute values of coefficients of thepartial block may be encoded through at least one of encoding a partialblock coefficient flag, encoding a first flag, encoding a second flag,or encoding a remaining coefficient.

In addition, above-described encoding coefficients of a partial blockmay further include a procedure of specifying a range of coefficientvalues belonging to the partial block. Through the above procedure, itmay be confirmed whether or not at least one non-zero coefficient existsin a partial block. The above procedure may be implemented through atleast one of (A) encoding a maximum value, (B) encoding a firstthreshold value flag or (C) encoding a second threshold value flag whichwill be described below. The above procedure may be implemented by beingincluded in any one of the above-described steps S600 to S650, or may beimplemented in a form that is substituted for at least one of steps S600to S650. Hereinafter, the procedure of specifying a range of coefficientvalues belonging to a partial block will be described in detail withreference to FIG. 7 to FIG. 8.

FIG. 7 is a diagram illustrating a method of encoding a maximum value ofa coefficient of a partial block as an embodiment to which the presentinvention is applied.

Referring to FIG. 7, a maximum value among absolute values ofcoefficients of a current partial block may be encoded (S700). Throughthe maximum value, a range of coefficient values belonging to thecurrent partial block may be inferred. For example, when the maximumvalue is m, coefficients of the current partial block may fall withinthe range of 0 to m. The maximum value may be selectively encodedaccording to a value of the partial block flag described above. Forexample, the maximum value may be encoded only when a current partialblock includes at least one non-zero coefficient (i.e., the partialblock flag is a first value). When coefficients of the current partialblock are all 0 (i.e., the partial block flag is a second value), themaximum value may be derived as 0.

In addition, through the maximum value, it may be determined whether ornot at least one non-zero coefficient is included in a current partialblock. For example, when the maximum value is greater than 0, thecurrent partial block includes at least one non-zero coefficient, andwhen the maximum value is 0, all coefficients of the current partialblock may be 0. Therefore, encoding the maximum value may be performedin place of the encoding of the partial block flag of S600.

FIG. 8 is a diagram illustrating a method of encoding a first thresholdvalue flag for a partial block as an embodiment to which the presentinvention is applied.

A first threshold value flag of the present invention may indicatewhether or not all coefficients of a partial block are smaller than apredetermined threshold value. The number of threshold values may be N(N>=1), where a range of threshold values may be represented by {T₀, T₁,T₂, . . . , T_(N−1)}. Here, the 0th threshold value T₀ denotes a minimumvalue, and the (N−1)-th threshold value T_(N−1) denotes a maximum value,and {T₀, T₁, T₂, . . . , T_(N−1)} may be those in which the thresholdvalues are arranged in ascending order. The number of the thresholdvalues may be predetermined in an image encoding device. The imageencoding device may determine an optimal number of threshold values inconsideration of encoding efficiency and encode the number.

The threshold value may be obtained by setting the minimum value to 1and increasing the minimum value by n (n>=1). The threshold value may bepredetermined in an image encoding device. The image encoding device maydetermine an optimal threshold value in consideration of the encodingefficiency and encode the threshold value.

The range of the threshold value may be determined differently dependingon a quantization parameter (QP). The QP may be set at a level of atleast one of a sequence, a picture, a slice, or a transform block.

For example, when the QP is greater than a predetermined QP threshold,it may be expected that the distribution of zero coefficients in atransform block will be higher. In this case, the range of the thresholdvalue may be determined as {3}, or the encoding procedure of thefirst/second threshold value flag may be omitted, and coefficients of apartial block may be encoded through steps S600 to S650 described above.

When the QP is smaller than a predetermined QP threshold, it may beexpected that the distribution of non-zero coefficients in a transformblock will be higher. In this case, the range of the threshold value maybe determined as {3, 5} or {5, 3}.

That is, the range of threshold values when QP is small may have thenumber and/or size (e.g., maximum value) of the threshold valuesdifferent from the threshold value range when QP is large. The number ofOP threshold values may be one, two, or more. The OP threshold value maybe predetermined in an image encoding device. For example, the QPthreshold value may correspond to a median value of a range of QPsavailable in the image encoding device. Alternatively, the imageencoding device may determine an optimal QP threshold value consideringencoding efficiency, and encode the OP threshold value.

Alternatively, a range of threshold values may be determined differentlydepending on the size/shape of a block. Here, a block may mean a codingblock, a prediction block, a transform block, or a partial block. Thesize may be represented by at least one of a width, a height, a sum of awidth and a height, or the number of coefficient.

For example, when a size of a block is smaller than a predeterminedthreshold size, a range of threshold values may be determined as {3}, orthe encoding procedure of the first/second threshold value flag may beomitted, and coefficients of a partial block may be encoded throughsteps S600 to S650 described above. When a size of a block is largerthan a predetermined threshold size, a range of threshold values may bedetermined as {3, 5} or {5, 3}.

That is, the range of threshold values when a block size is small mayhave the number and/or size (e.g., maximum value) of the thresholdvalues different from the threshold value range when a block size islarge. The number of threshold size may be one, two, or more. Thethreshold size may be predetermined in an image encoding device. Forexample, the threshold size may be represented by a×b, wherein a and bare 2, 4, 8, 16, 32, 64 or more, and a and b may be equal to ordifferent from each other. Alternatively, the image encoding device maydetermine an optimal threshold size considering encoding efficiency, andencode the threshold size.

Alternatively, the range of threshold values may be determineddifferently depending on a range of pixel values. The range of pixelvalues may be represented by a maximum value and/or a minimum value ofpixels belonging to a predetermined region. Here, the predeterminedregion may mean at least one of a sequence, a picture, a slice, or ablock.

For example, when the difference between the maximum value and theminimum value of the range of pixel values is smaller than apredetermined threshold difference value, the range of threshold valuesis determined as {3}, or the encoding procedure of the first/secondthreshold value flag may be omitted, and coefficients of a partial blockmay be encoded through steps S600 to S650 described above. When thedifference is larger than a predetermined threshold difference value,the range of threshold values may be determined as {3, 5} or {5, 3}.

That is, the range of threshold values when the difference is small mayhave the number and/or size (e.g., maximum value) of the thresholdvalues different from a range of threshold values when the difference islarge. The number of threshold difference values may be one, two, ormore. The threshold difference value may be predetermined in an imageencoding device. Alternatively, the image encoding device may determinean optimal threshold difference value considering encoding efficiency,and encode the threshold difference value.

Referring to FIG. 8, it may be determined whether absolute values of allcoefficients in a current partial block is smaller than a currentthreshold value (S800).

When the absolute values of all coefficients are not smaller than thecurrent threshold value, a first threshold value flag may be encoded as“false” (S810). In this case, the current threshold value (i-ththreshold value) may be updated to the next threshold value ((i+1)-ththreshold value) (S820), and the above described step S800 may beperformed based on the updated current threshold value. Alternatively,when absolute values of all coefficients are not smaller than thecurrent threshold value, the first threshold value flag encodingprocedure of step S810 may be omitted, and the current threshold valuemay be updated to the next threshold value.

When the current threshold value reaches a maximum value of a thresholdvalue or when the number of the threshold values is 1, the currentthreshold value may be updated by adding a predetermined constant to thecurrent threshold value. The predetermined constant may be an integergreater than or equal to one. Here, the update may be repeatedlyperformed until the first threshold value flag is encoded as “true”.Based on the updated current threshold value, step S800 may beperformed. Alternatively, when the current threshold value reaches themaximum value of the threshold value or when the number of thresholdvalues is 1, the updating procedure may be terminated.

When absolute values of all coefficients are smaller than a currentthreshold value, the first threshold value flag may be encoded as “true”(S830).

As described above, when the first threshold value flag for the i-ththreshold value is “true”, this may indicate that absolute values of allcoefficients in a partial block are smaller than the i-th thresholdvalue. When the first threshold value flag for the i-th threshold is“false”, this may indicate that absolute values of all coefficients inthe partial block is greater than or equal to the i-th threshold. Basedon the first threshold flag that is “true”, a range of coefficientvalues belonging to the partial block may be specified. That is, whenthe first threshold value flag for the i-th threshold value is “true”,the coefficient belonging to the partial block may fall within the rangeof 0 to (i-th threshold value−1).

According to the encoded first threshold value flag, at least one ofsteps S600 to S650 described above may be omitted.

For example, when a range of threshold values is {3, 5}, at least one ofthe first threshold value flag for the threshold value “3” or the firstthreshold value flag for the threshold value “5” may be encoded. Whenthe first threshold value flag for the threshold value “3” is “true”,absolute values of all coefficients in the partial block may fall withinthe range of 0 to 2. In this case, coefficients of the partial block maybe encoded by performing the remaining steps except at least one of theabove-described steps S630 or S640, or the coefficients of the partialblock may be encoded by performing the remaining steps except at leastone of S600. S630 or S640.

When the first threshold value flag for the threshold “3” is “false”,the first threshold value flag for the threshold “5” may be encoded.When the first threshold value flag for the threshold “5” is “false”, atleast one of absolute values of coefficients in a partial block may begreater than or equal to 5. In this case, coefficients of the partialblock may be encoded by performing the above-described steps S600 toS650 in the same manner, or coefficients of the partial block may beencoded by performing the remaining steps except step S600.

When the first threshold value flag for the threshold “5” is “true”,absolute values of all coefficients in the partial block may fall withinthe range of 0 to 4. In this case, coefficients of the partial block maybe encoded by performing the above-described steps S600 to S650 in thesame manner, or coefficients of the partial block may be encoded byperforming the remaining steps except step S600.

In addition, a first threshold value flag of a current partial block maybe derived based on a first threshold flag of another partial block. Inthis case, the encoding procedure of the first threshold value flag maybe omitted, and this will be described with reference to FIG. 14.

FIG. 9 is a diagram illustrating a method of decoding coefficients of atransform block as an embodiment to which the present invention isapplied.

Coefficients of a transform block may be decoded in units of apredetermined block (hereinafter, referred to as a partial block) in animage decoding device. A transform block may include one or more partialblocks. A partial block may be a block of N×M size. Here, N and M arenatural numbers, and N and M may be equal to or different from eachother. That is, a partial block may be a square or a non-square block. Asize/shape of a partial block may be fixed (e.g., 4×4) predefined in animage decoding device, may be variably determined depending on asize/shape of a transform block, or may be variably determined based onsignaled information on a size/shape of a partial block. Information ona size/shape of a partial block may be signaled in a level of at leastone of a sequence, a picture, a slice or a block.

An order of decoding partial blocks belonging to a transform block maybe determined according to a predetermined scan type (hereinafter,referred to as a first scan type) in an image decoding device. Inaddition, an order of decoding coefficients belonging to a partial blockmay be determined according to a predetermined scan type (hereinafter,referred to as a second scan type). The first scan type and the secondscan type may be the same or different. For the first/second scan type,a diagonal scan, a vertical scan, a horizontal scan and the like may beused. However, the present invention is not limited thereto, and one ormore scan types having predetermined angles may be further added. Thefirst/second scan type may be determined based on at least one of codingblock related information (e.g., maximum/minimum size, partitioningtechnique, etc.), size/shape of transform block, size/shape of partialblock, prediction mode, intra-prediction related information (e.g., avalue of intra-prediction mode, directionality, angle, etc.) orinter-prediction related information.

An image decoding device may decode, in a transform block, positioninformation of a coefficient (hereinafter, referred to as a non-zerocoefficient) having non-zero value first appeared in the above-describeddecoding order. Decoding may be performed sequentially from a partialblock according to the position information. Hereinafter, a procedure ofdecoding coefficients of a partial block will be described withreference to FIG. 9.

A partial block flag for a current partial block may be decoded (S900).The partial block flag may be decoded in units of a partial block. Thepartial block flag may indicate whether there is at least one non-zerocoefficient in the current partial block. For example, when the partialblock flag is a first value, it may indicate that the current partialblock includes at least one non-zero coefficient, and when the partialblock flag is a second value, it may indicate that all coefficients ofthe current partial block are 0.

A partial block coefficient flag for a current partial block may bedecoded (S910). The partial block coefficient flag may be decoded inunits of a coefficient. The partial block coefficient flag may indicatewhether the coefficient is a non-zero coefficient. For example, when thepartial block coefficient flag is a first value, it may indicate thatthe coefficient is a non-zero coefficient, and when the partial blockcoefficient flag is a second value, it may indicate that the coefficientis zero. The partial block coefficient flag may be selectively decodedaccording to the partial block flag. For example, a current partialblock may be decoded for each coefficient of a partial block only whenthere is at least one non-zero coefficient present in the currentpartial block (i.e., the partial block flag is a first value).

A flag (hereinafter, referred to as a first flag) indicating whether anabsolute value of a coefficient is greater than 1 may be decoded (S920).The first flag may be selectively decoded according to a value of thepartial block coefficient flag. For example, when the coefficient is anon-zero coefficient (i.e., the partial block coefficient flag is afirst value), the first flag may be decoded to check whether theabsolute value of the coefficient is greater than 1. When the first flagis a first value, the absolute value of the coefficient is greater than1, and when the first flag is a second value, the absolute value of thecoefficient may be 1.

A flag (hereinafter, referred to as a second flag) indicating whether anabsolute value of a coefficient is greater than 2 may be decoded (S930).The second flag may be selectively decoded according to a value of thefirst flag. For example, when the coefficient is greater than 1 (i.e.,the first flag is a first value), the second flag may be decoded tocheck whether the absolute value of the coefficient is greater than 2.When the second flag is a first value, the absolute value of thecoefficient is greater than 2, and when the second flag is a secondvalue, the absolute value of the coefficient may be 2.

The number of at least one of the first flag or the second flag may beat least one to at most N*M. Alternatively, at least one of the firstflag or the second flag may be a fixed number (e.g., one, two, or more)predefined in an image decoding device. The number of the first/secondflag may be different depending on a bit depth of an input image, adynamic range of an original pixel value in a certain region of animage, a block size/depth, a partitioning technique (e.g., quad tree,binary tree), a transforming technique (e.g., DCT, DST), whether to skiptransform, quantization parameters, prediction mode (e.g., intra/intermode), and so on. In addition to the first/second flag, an n-th flagindicating whether an absolute value of a coefficient is greater than nmay be additionally decoded. Here, n may mean a natural number greaterthan two. The number of the n-th flag may be one, two, or more, and maybe determined in the same/similar manner as the first/second flagdescribed above.

Remaining coefficients that are not decoded based on the first/secondflag may be decoded in a current partial block (S940). Here, thedecoding may be a procedure of decoding the coefficient value itself.The remaining coefficients may be equal to or greater than two.

A sign for a coefficient of a partial block may be decoded (S950). Thesign may be decoded in a flag format in units of a coefficient. The signmay be selectively decoded according to a value of the partial blockcoefficient flag described above. For example, the sign may be decodedonly when the coefficient is a non-zero coefficient (i.e., the partialblock coefficient flag is a first value).

In addition, above-described decoding coefficients of a partial blockmay further include a procedure of specifying a range of coefficientvalues belonging to the partial block. Through the above procedure, itmay be confirmed whether or not at least one non-zero coefficient existsin a partial block. The above procedure may be implemented through atleast one of (A) decoding a maximum value, (B) decoding a firstthreshold value flag or (C) decoding a second threshold value flag whichwill be described below. The above procedure may be implemented by beingincluded in any one of the above-described steps S900 to S950, or may beimplemented in a form that is substituted for at least one of steps S900to S950. Hereinafter, the procedure of specifying a range of coefficientvalues belonging to a partial block will be described in detail withreference to FIG. 10 to FIG. 11.

FIG. 10 is a diagram illustrating a method of decoding a maximum valueof a coefficient of a partial block as an embodiment to which thepresent invention is applied.

Referring to FIG. 10, information indicating a maximum value amongabsolute values of coefficients of a current partial block may bedecoded (S1000). A range of coefficient values belonging to the currentpartial block may be inferred through the maximum value according to theinformation. For example, when the maximum value is m, coefficients ofthe current partial block may fall within the range of 0 to m. Theinformation indicating the maximum value may be selectively decodedaccording to a value of the partial block flag described above. Forexample, a current partial block may be decoded only when the currentpartial block includes at least one non-zero coefficient (i.e., thepartial block flag is a first value). When coefficients of the currentpartial block are all 0 (i.e., the partial block flag is the secondvalue), the information indicating the maximum value may be derived aszero.

Also, through the maximum value according to the information, it may bedetermined whether or not at least one non-zero coefficient is includedin a current partial block. For example, when the maximum value isgreater than 0, the current partial block includes at least one non-zerocoefficient, and when the maximum value is 0, all coefficients of thecurrent partial block may be zero. Therefore, the decoding the maximumvalue may be performed in place of the decoding of the partial blockflag of S900.

FIG. 11 is a diagram illustrating a method of decoding a first thresholdvalue flag for a partial block as an embodiment to which the presentinvention is applied.

A first threshold flag of the present invention may indicate whether ornot all coefficients of a partial block are smaller than a predeterminedthreshold value. The number of threshold values may be N (N>=1), where arange of threshold values may be represented by {T₀, T₁, T₂, . . . ,T_(N−1)}. Here, the 0th threshold value T₀ may denote a minimum value,and the (N−1)-th threshold value T_(N−1) may denotes a maximum value,and {T₀, T₁, T₂, . . . , T_(N−1)} may be those in which the thresholdvalues are arranged in ascending order. The number of threshold valuesmay be predetermined in an image decoding device or may be determinedbased on signaled information on the number of threshold values.

The threshold value may be obtained by setting a minimum value to 1 andincreasing the minimum value by n(n>=1). The threshold value may be setin an image decoding device or may be determined based on signaledinformation on a threshold value.

A range of threshold values may be determined differently depending on aquantization parameter (QP). The QP may be set at a level of at leastone of a sequence, a picture, a slice, or a transform block.

For example, when the QP is larger than a predetermined QP thresholdvalue, a range of threshold values may be determined as {3}, or thefirst/second threshold value flag decoding procedure may be omitted, andthrough the above-described steps of S900 to S950 coefficients of apartial block may be decoded.

In addition, when the OP is smaller than a predetermined QP threshold, arange of threshold values may be determined as {3, 5} or {5, 3}.

That is, a range of threshold values when the QP is small may have thenumber and/or size (e.g., maximum value) of threshold values differentfrom a range of threshold values when the QP is large. The number of QPthreshold values may be one, two, or more. The QP threshold value may beset in an image decoding device. For example, the QP threshold value maycorrespond to a median value of a range of QPs available in an imagedecoding device. Alternatively, the QP threshold value may be determinedbased on information on the QP threshold value signaled by an imageencoding device.

Alternatively, a range of threshold values may be determined differentlydepending on a size/shape of a block. Here, a block may mean a codingblock, a prediction block, a transform block, or a partial block. Thesize may be represented by at least one of a width, a height, a sum of awidth and a height, or the number of coefficients.

For example, when a block size is smaller than a predetermined thresholdsize, a range of threshold values may be determined as {3}, or thefirst/second threshold value flag decoding procedure may be omitted, andcoefficients of a partial block may be decoded through steps S900 toS950 described above. In addition, when a block size is larger than apredetermined threshold size, a range of threshold values may bedetermined as {3, 5} or {5, 3}.

That is, a range of threshold values when a block size is small may havethe number and/or size (e.g., maximum value) of threshold valuesdifferent from a range of threshold values when a block size is large.The number of threshold size may be one, two, or more. The thresholdsize may be set in an image decoding device. For example, the thresholdsize may be represented by a×b, where a and b are 2, 4, 8, 16, 32, 64 ormore, and a and b may be the same or different. Alternatively, thethreshold size may be determined based on information on a thresholdsize signaled by an image encoding device.

Alternatively, a range of threshold values may be determined differentlydepending on a range of pixel values. The range of pixel values may berepresented by a maximum value and/or a minimum value of pixelsbelonging to a predetermined region. Here, the predetermined region maymean at least one of a sequence, a picture, a slice, or a block.

For example, when a difference between a maximum value and a minimumvalue of a range of pixel values is smaller than a predeterminedthreshold difference value, a range of threshold values may bedetermined as {3}, or the first/second threshold value flag decodingprocedure may be omitted, and coefficients of a partial block may bedecoded through steps S900 to S950 described above. In addition, whenthe difference is larger than a predetermined threshold differencevalue, the range of threshold values may be determined as {3, 5} or {5,3}.

That is, a range of threshold values when the difference is small mayhave the number and/or size (e.g., maximum value) of threshold valuesdifferent from a range of threshold values when the difference is large.The number of threshold difference values may be one, two, or more. Thethreshold difference value may be set in an image decoding device or maybe determined based on information on a threshold difference valuesignaled by an image encoding device.

Referring to FIG. 11, a first threshold value flag for a currentthreshold value may be decoded (S1100).

The first threshold value flag may indicate whether absolute values ofall coefficients of a partial block are smaller than a current thresholdvalue. For example, when the first threshold value flag is “false”, itmay indicate that absolute values of all coefficients of a partial blockare greater than or equal to a current threshold. In addition, when thefirst threshold value flag is “true”, it may indicate that absolutevalues of all coefficients of a partial block are smaller than a currentthreshold value.

When the first threshold value flag is “false”, the current thresholdvalue (i-th threshold value) may be updated to the next threshold value((i+1-th threshold value) (S1110), based on the updated currentthreshold value, step S1100 described above may be performed.

When the current threshold value reaches a maximum value of thresholdvalues or when the number of threshold values is 1, the currentthreshold value may be updated by adding a predetermined constant to thecurrent threshold value. The predetermined constant may be an integergreater than or equal to one. Here, the update may be repeatedlyperformed until the first threshold value that is “true” is decoded.Alternatively, when the current threshold value reaches a maximum valueof threshold values or when the number of threshold values is 1, theupdating procedure may be terminated.

As shown in FIG. 11, when the first threshold value flag is “true”,decoding of a first threshold value flag may not be performed any more.

As described above, when a first threshold value flag for the i-ththreshold value is “true”, it may indicate that absolute values of allcoefficients in a partial block are smaller than the i-th thresholdvalue. In addition, when a first threshold flag for the i-th thresholdvalue is “false”, it may indicate that absolute values of allcoefficients in a partial block are greater than or equal to the i-ththreshold value. Based on the first threshold value flag that is “true”,a range of coefficient values belonging to a partial block may bespecified. That is, when a first threshold value flag for the i-ththreshold value is “true”, a coefficient belonging to a partial blockmay fall within a range of 0 to (i-th threshold value−1).

According to the decoded first threshold value flag, at least one ofsteps S900 to S950 described above may be omitted.

For example, when a range of threshold values is {3, 5}, at least one ofa first threshold value flag for the threshold value “3” or a firstthreshold value flag for the threshold value “5” may be decoded. Whenthe first threshold value flag for the threshold value “3” is “true”,absolute values of all coefficients in a partial block may fall withinthe range of 0 to 2. In this case, coefficients of a partial block maybe decoded by performing the remaining steps except at least one of thesteps S930 or S940 described above, or coefficients of a partial blockmay be decoded by performing the remaining steps except at least one ofthe steps S900, S930 or S940 described above.

When the first threshold value flag for the threshold value “3” is“false”, the first threshold value flag for the threshold value “5” maybe decoded. When the first threshold value flag for the threshold value“5” is “false”, at least one of absolute values of coefficients in apartial block may be greater than or equal to 5. In this case,coefficients of a partial block may be decoded by performing theabove-described steps S900 to S950 in the same manner, or coefficientsof a partial block may be decoded by performing the remaining stepsexcept step S900.

In addition, when the first threshold value flag for the threshold value“5” is “true”, absolute values of all coefficients in a partial blockmay fall within the range of 0 to 4. In this case, coefficients of apartial block may be decoded by performing the above-described stepsS900 to S950 in the same manner, or coefficients of a partial block maybe decoded by performing the remaining steps except step S900.

In addition, a first threshold value flag of a current partial block maybe derived based on a first threshold value flag of another partialblock. In this case, decoding procedure for a first threshold value flagmay be omitted, and this will be described with reference to FIG. 12.

FIG. 12 is a diagram illustrating a method of deriving a first/secondthreshold value flag for a current partial block as an embodiment towhich the present invention is applied.

In this embodiment, it is assumed that a transform block 1100 is 8×8, apartial block is 4×4, a block including a non-zero coefficient that isfirst appeared is 1220, and partial blocks of the transform block areencoded/decoded in an order of 1240, 1220, 1230, 1210 depending on scantype.

In a current partial block, a first threshold value flag for aparticular threshold value may be derived based on a first thresholdvalue flag of a previous partial block. For example, based on a firstthreshold value flag that is “false” in a previous partial block, afirst threshold value flag of a current partial block may be derived as“false”. Here, it is assumed that {3, 5, 7} is used as a range ofthreshold values.

Specifically, since the partial block 1240 which is a first place in theencoding/decoding order has earlier encoding/decoding order than aposition of the partial block 1220 to which a non-zero coefficient thatis first appeared belongs, a first threshold value flag may not beencoded/decoded. In the partial block 1220 which is a second place inthe encoding/decoding order, since the first threshold value flag forthe threshold value “3” is “true”, only the first threshold flag for thethreshold value “3” may be encoded/decoded. In the partial block 1230which is a third place in the encoding/decoding order, since the firstthreshold value flag for the threshold value “3” is “false” and thefirst threshold value flag for the threshold value “5” is “true”, thefirst threshold flags for the threshold value “3” and “5” may berespectively encoded/decoded. In the partial block 1210 which is a lastplace in the encoding/decoding order, the first threshold value flag forthe threshold value “3” is “false” and the first threshold value flagfor the threshold value “5” is “false”. Here, since the first thresholdflag for the threshold value “3” in the previous partial block 1230 is“false”, it may be expected that the current partial block 1210 has atleast one coefficient that has absolute value equal to or greater than3, the first threshold value flag for the threshold value “3” may bederived as “false”.

In a current partial block, a first threshold value flag for aparticular threshold value may be derived based on a first thresholdvalue flag of a previous partial block. For example, based on a firstthreshold value flag that is “false” in a previous partial block, thefirst threshold value flag of the current partial block may be derived“false”.

Hereinafter, referring to FIG. 13 to FIG. 18, a method of determining apartial block of a transform block will be described in detail.

An image encoding device may determine a partial block having apredetermined size/shape constituting a transform block, and may encodeinformation on the size/shape of the partial block. An image decodingdevice may determine a size/shape of a partial block based on theencoded information (first method). Alternatively, a size/shape of apartial block may be determined through a predetermined rule in an imageencoding/decoding device (second method). Information indicating whetherto determine a size/shape of a partial block through which one of thefirst and second methods may be signaled in at least one layer of avideo, a sequence, a picture, a slice, or a block. The block may referto a coding block, a prediction block or a transform block.

A size of a partial block in a transform block may be equal to orsmaller than a size of the transform block. A shape of the transformblock/partial block may be square or non-square. A shape of a transformblock may be the same as or different from a shape of a partial block.

Information on a shape of a transform block may be encoded. Here, theinformation may include at least one of information on whether to useonly a square, a non-square, or both a square and a non-square for ashape of a transform block. The information may be signaled in at leastone layer of a video, a sequence, a picture, a slice, or a block. Theblock may refer to a coding block, a prediction block, or a transformblock. Information on a size of a transform block may be encoded. Here,the information may include at least one of a minimum size, a maximumsize, a partitioning depth or a maximum/minimum value for a partitioningdepth. The information may be signaled in at least one layer of a video,a sequence, a picture, a slice, or a block.

Information on a shape of a partial block may be encoded. Here, theinformation may include at least one of information on whether to useonly a square, a non-square, or both a square and a non-square for ashape of a partial block. The information may be signaled in at leastone layer of a video, a sequence, a picture, a slice, or a block. Theblock may refer to a coding block, a prediction block, or a transformblock. Information on a size of a partial block may be encoded. Here,the information may include at least one of a minimum size, a maximumsize, a partitioning depth, and a maximum/minimum value for apartitioning depth. The information may be signaled in at least onelayer of a video, a sequence, a picture, a slice, or a block.

FIG. 13 is a diagram illustrating a method of determining a size/shapeof a partial block based on a merge flag as an embodiment to which thepresent invention is applied.

An image encoding device may check a partial block in which merge shapeis optimal through an RDO from a partial block of a minimum size to apartial block of a maximum size.

Referring to FIG. 13, an RD-cost value for a transform block 1301including a plurality of partial blocks 1-16 may be calculated. Thepartial block may be a partial block of a minimum size predetermined inan image encoding device. The transform block 1302 is a case where thefour partial blocks 13-16 of the transform block 1301 are merged intoone partial block, and an RD-cost value for the transform block 1302 maybe calculated. The transform block 1303 is a case where the four partialblocks 9-12 of the transform block 1301 are merged into one partialblock, and an RD-cost value for the transform block 1303 may becalculated. The transform block 1304 is a case where the four partialblocks 5-8 of the transform block 1301 are merged into one partialblock, and an RD-cost value for the transform block 1304 may becalculated.

An image encoding device may calculate, using a quad tree method,RD-cost values while merging partial blocks in a transform block up to apartial block of a maximum size. An optimal merge is determined based onthe RD-cost value, and a merge flag indicating the optimal merge may beencoded. The image decoding device may determine a size/shape of apartial block in a transform block based on the encoded merge flag.

For example, it may be assumed that the transform block 1304 is theoptimal merge, the minimum size of the partial block is equal to thesize of the partial block “1” of the transform block 1304, and themaximum size of the partial block is equal to the size of the partialblock “5” of the transform block 1304. In this case, an image encodingdevice may encode a merge flag “false” indicating that the transformblock 1301 is not an optimal merge. In addition, a merge flag “false”indicating that a state that the four partial blocks 10-13 of transformblock 1304 are not merged is an optimal merge may be encoded, and amerge flag “false” indicating that a state that the four partial blocks6-9 of transform block 1304 are not merged is optimal may be encoded.Further, a merge flag “true” indicating that a state that the fourpartial blocks 6-9 of transform block 1304 are merged into one partialblock is optimal may be encoded, and a merge flag “false” indicatingthat a state that the four partial blocks 1-4 of transform block 1304are not merged is optimal may be encoded. That is, the image encodingdevice may generate a bitstream “00010” through the encoding, and theimage decoding device may decode the bitstream to determine a mergeshape of the transform block 1304.

FIG. 13 does not limit a merging order of partial blocks, but thepartial blocks may be merged in a different order. The above merging maybe performed within a range of block size/shape predetermined in theimage encoding/decoding device. The shape of the merged partial blockmay be square or non-square. The shape of the merged partial block maybe determined based on an encoding order or a scanning order of thepartial blocks.

For example, when an encoding order of partial blocks in a transformblock is diagonal direction, square-shaped merge may be used.Alternatively, when an encoding order of partial blocks in a transformblock is vertical direction, a vertically long non-square-shaped mergemay be used. Alternatively, when an encoding order of partial blocks ina transform block is horizontal direction, horizontally longnon-square-shaped merge may be used.

FIG. 14 is a diagram illustrating a method of determining a size/shapeof a partial block based on a partitioning flag as an embodiment towhich the present invention is applied.

An image encoding device may check a transform block in whichpartitioning shape is optimal through an RDO from a partial block of amaximum size to a partial block of a minimum size.

Referring to FIG. 14, an RD-cost value for a transform block 1401including one partial block 1 may be calculated. The partial block 1 maybe a partial block of a maximum size predetermined in an image encodingdevice. The transform block 1302 is a case where a maximum size partialblock is partitioned into four partial blocks 1-4, and an RD-cost valuefor the transform block 1302 may be calculated. The transform block 1403is a case where a partial block 1 of the transform block 1401 ispartitioned into four partial blocks 1-4, and an RD-cost value for thetransform block 1403 may be calculated. The transform block 1404 is acase where a partial block 1 of the transform block 1403 is partitionedagain into four partial blocks 1-4, and an RD-cost value for thetransform block 1404 may be calculated.

An image encoding device may calculate, using a quad tree method,RD-cost values while partitioning partial blocks in a transform block upto a partial block of a minimum size. An optimal partitioning isdetermined based on the RD-cost value, and a partitioning flagindicating the optimal partitioning may be encoded. The image decodingdevice may determine a size/shape of a partial block in a transformblock based on the encoded partitioning flag.

For example, it may be assumed that the transform block 1403 is theoptimal partitioning, the minimum size of the partial block is equal tothe size of the partial block “1” of the transform block 1403, and themaximum size of the partial block is equal to the size of the transformblock 1403. In this case, an image encoding device may encode apartitioning flag “true” indicating that the transform block 1401 is notan optimal partitioning. In addition, a partitioning flag “true”indicating that a state that the partial block ‘1’ of the transformblock 1402 is partitioned into four partial blocks is an optimalpartitioning may be encoded. A partitioning flag “false” indicating thata state that the remaining partial blocks 2-4 of the transform block1402 are not partitioned into four partial blocks is an optimalpartitioning may be encoded. That is, the image encoding device maygenerate a bitstream “11000” through the encoding, and the imagedecoding device may decode the bitstream to determine a partitioningshape of the transform block 1403.

FIG. 14 does not limit a partitioning order of partial blocks, but thepartial blocks may be partitioned a in a different order. Theabove-described partitioning may be performed within a range of blocksize/shape predetermined in the image encoding/decoding device. Theshape of the partitioned partial block may be square or non-square. Theshape of the partitioned partial block may be determined based on anencoding order or a scanning order of the partial blocks.

For example, when an encoding order of partial blocks in a transformblock is diagonal direction, square-shaped partitioning may be used.Alternatively, when an encoding order of partial blocks in a transformblock is vertical direction, a vertically long non-square-shapedpartitioning may be used. Alternatively, when an encoding order ofpartial blocks in a transform block is horizontal direction,horizontally long non-square-shaped partitioning may be used.

FIG. 15 is a diagram illustrating a method of determining a size/shapeof a partial block based on partitioning index information as anembodiment to which the present invention is applied.

An image encoding device may determine which partitioning shape of apartial block is the most optimal through RDO, from when all partialblocks of a transform block have maximum size until when all partialblocks have minimum size.

Referring to FIG. 15, a transform block 1501 is composed of one partialblock 1, and an RD-cost value in this case may be calculated. Thepartial block 1 may be a partial block of a maximum size predefined inan image encoding device. A transform block 1502 is a case where thetransform block 1501 is partitioned into four partial blocks 1-4, and anRD-cost value in this case may be calculated. A transform block 1503 isa case where each partial block of the transform block 1502 is againpartitioned into four partial blocks, and an RD-cost value in this casemay be calculated.

As described above, within a range of a partial block of a maximum sizeto a minimum size, RD-cost values may be calculated while partitioning atransform block into partial blocks of the same size. An optimalpartitioning is determined based on the RD-cost values, and apartitioning index information indicating optimal partitioning may beencoded. An image decoding device may determine a size/shape of apartial block in a transform block based on the encoded partitioningindex information.

For example, when a transform block 1501 is the optimum partitioning, animage encoding device may encode “0” as a partitioning indexinformation, and when a transform block 1502 is the optimumpartitioning, an image encoding device may encode “1” as a partitioningindex information, when a transform block 1503 is the optimumpartitioning, an image encoding device may encode “2” as a partitioningindex information, respectively. An image decoding device may determinea size/shape of a partial block in a transform block based on theencoded partitioning index information.

FIG. 16 is a diagram illustrating a method of partitioning a transformblock based on a position of a non-zero coefficient as an embodiment towhich the present invention is applied.

In a transform block, a size/shape of a partial block may be determinedbased on a position of a non-zero coefficient first appeared in anencoding/decoding order.

A size/shape of a partial block may be determined as a size/shape of ablock (hereinafter, referred to as a first reference block) including aposition of a non-zero coefficient first appeared. The first referenceblock may be a block having a minimum size among blocks including theposition of the non-zero coefficient first appeared and a position ofright bottom coefficient of a transform block. Here, the first referenceblock may belong to a range of a minimum size and a maximum size ofpartial blocks predetermined in an image encoding/decoding device. Thetransform block may be partitioned according to the determinedsize/shape of partial blocks.

For example, when a transform block 1601 is 16×16 and a position of anon-zero coefficient first appeared in an encoding/decoding order is(12, 12) with respect to left top (0, 0) of the transform block, a sizeof a partial block including the coefficient (12, 12) may be determinedas 4×4, and the transform block 1601 may be partitioned into 16 partialblocks of 4×4 size as shown in FIG. 16. Alternatively, when thetransform block 1602 is 16×16 and a position of a non-zero coefficientfirst appeared in an encoding/decoding order is (8, 8) with respect toleft top (0, 0) of the transform block, a size of a partial blockincluding the coefficient (8, 8) may be determined as 8×8, and thetransform block 1602 may be partitioned into 4 partial blocks of 8×8size as shown in FIG. 16. Alternatively, when the transform block 1603is 16×16 and a position of a non-zero coefficient first appeared in anencoding/decoding order is (8, 0) with respect to left top (0, 0) of thetransform block, a size of a partial block including the coefficient (8,0) may be determined as 8×16, and the transform block 1603 may bepartitioned into 2 partial blocks of 8×16 size.

Alternatively, a size/shape of the partial block may be determined as asize/shape of a block (hereinafter, referred to as a second referenceblock) that does not include a position of a non-zero coefficient firstappeared. The second reference block may be a block having a maximumsize among blocks not including the position of the non-zero coefficientfirst appeared and including a position of right bottom coefficient of atransform block. Here, the second reference block may belong to a rangeof a minimum size and a maximum size of partial blocks predetermined inan image encoding/decoding device. The transform block may bepartitioned according to the determined size/shape of partial blocks.

For example, when a transform block 1601 is 16×16 and a position of anon-zero coefficient first appeared in an encoding/decoding order is(12, 11) with respect to left top (0, 0) of the transform block, a sizeof a partial block not including the coefficient (12, 11) may bedetermined as 4×4, and the transform block 1601 may be partitioned into16 partial blocks of 4×4 size. Alternatively, when a transform block1602 is 16×16 and a position of a non-zero coefficient first appeared inan encoding/decoding order is (7, 13) with respect to left top (0, 0) ofthe transform block, a size of a partial block not including thecoefficient (7, 13) may be determined as 8×8, and the transform block1602 may be partitioned into 4 partial blocks of 8×8 size.Alternatively, when a transform block 1603 is 16×16 and a position of anon-zero coefficient first appeared in an encoding/decoding order is (6,14) with respect to left top (0, 0) of the transform block, a size of apartial block not including the coefficient (6, 14) may be determined as8×16, and the transform block 1603 may be partitioned into 2 partialblocks of 8×16 size.

FIG. 17 is a diagram illustrating a method of selectively partitioning apartial region of a transform block as an embodiment to which thepresent invention is applied.

In a transform block, a remaining region excluding a partial region maybe partitioned into partial blocks having a predetermined size/shape.Here, the partial region may be specified based on a position (a, b) ofa non-zero coefficient first appeared. For example, the partial regionmay include at least one of a region having x-coordinate larger than thea or a region having y-coordinate larger than the b. Here, a size/shapeof a partial block may be determined in the same/similar manner as theabove-described at least one embodiment, and a detailed descriptionthereof will be omitted.

For example, when the transform block 1701 is 16×16 and the position ofthe non-zero coefficient first appeared in the encoding/decoding orderis (11, 11) with respect to left top (0, 0) of the transform block,regions located in right side of x-coordinate of (11, 11) and regionslocated in bottom side of y-coordinate of (11, 11) may be excluded froma partial block setting range and may not be encoded/decoded. Here, theremaining region of the transform block 1701 may be partitioned into 4partial blocks of 6×6 size.

Alternatively, in a transform block, a remaining region excluding apartial region may be partitioned into partial blocks having apredetermined size/shape. Here, the partial region may be specifiedbased on a position (a, b) of a non-zero coefficient first appeared anda maximum coordinate value (c, d) of the transform block. The maximumcoordinate value (c, d) may be a position of right bottom coefficient ofthe transform block. For example, “(c−a)” and “d−b” which aredifferences between the position (a, b) of the non-zero coefficientfirst appeared and the maximum coordinate value (c, d) of the transformblock may be calculated, respectively. A position (e, f) shifted by aminimum value of the difference value may be determined with respect tothe position of the right bottom coefficient of the transform block.Here, the partial region may include at least one of a region havingx-coordinate larger than the e or a region having y-coordinate largerthan the f. Here, a size/shape of a partial block may be determined inthe same/similar manner as the above-described at least one embodiment,and a detailed description thereof will be omitted.

For example, when the transform block 1701 is 16×16 and the position ofthe non-zero coefficient first appeared in the encoding/decoding orderis (11, 8) with respect to left top (0, 0) of the transform block, adifference “4” between the x-coordinate “11” of the correspondingcoefficient and the maximum x-coordinate “15” of the transform block maybe calculated, and a difference “7” between the y-coordinate “8” of thecorresponding coefficient and the maximum y-coordinate “15” of thetransform block may be calculated. With respect to the position of theright bottom coefficient of the transform block, a position shifted by aminimum value “4” among the difference values may be determined as (11,11). In this case, regions located in right side of x-coordinate of (11,11) and regions located in bottom side of y-coordinate of (11, 11) maybe excluded from a partial block setting range and may not beencoded/decoded. Here, the remaining region of the transform block 1701may be partitioned into 4 partial blocks of 6×6 size.

Alternatively, the transform block may be partitioned into a pluralityof regions based on a predetermined boundary line. The boundary line maybe one, two, or more. The boundary line has a slope of a predeterminedangle, and the angle may fall within a range of 0 to 90 degrees. Theboundary line may include the position of the non-zero coefficient firstappeared in the encoding/decoding order of coefficients in the transformblock. Specifically, with respect to the boundary line, the transformblock may be partitioned into a first region and a second region. Here,the first region may be partitioned into partial blocks having apredetermined size/shape, and the second region may not be partitionedinto partial blocks having a predetermined size/shape. That is, thecoefficients belonging to the first region are encoded/decoded based ona partial block having a predetermined size/shape, and encoding/decodingfor coefficients belonging to the second region may be skipped. Thefirst region may refer to a region located in a top, left, or left topside with respect to the boundary line. In this case, the first regionmay further include a partial block region including the boundary line.The second region may refer to a region located in a bottom, right, orright bottom side with respect to the boundary line.

For example, it may be assumed that the transform block 1402 is 16×16,the position of the non-zero coefficient first appeared in theencoding/decoding order is (10, 6) with respect to left top (0, 0) ofthe transform block, and all partial blocks of the transform block 1402have been partitioned into 4×4 units. In this case, with respect to (10,6), the last pixel position in the 45-degree direction to a right topcorner is (15, 1) and the last pixel position in the 45-degree directionto a left bottom corner is (1, 15). With respect to the boundary lineconnecting the two pixel positions, partial blocks 1-10 located in aleft top region may be determined as partial blocks to beencoded/decoded, and partial blocks located in a right bottom region maybe determined as partial blocks not to be encoded/decoded. Here, shapeof partial blocks in the left top region may be determined as aquadrangle and/or a triangle.

For example, it may be assumed that the transform block 1403 is 16×16,the position of the non-zero coefficient first appeared in theencoding/decoding order is (8, 7) with respect to left top (0, 0) of thetransform block, and all partial blocks of the transform block 1403 havebeen partitioned into 4×4 units. In this case, with respect to (8, 7),the last pixel position in the 45-degree direction to a right top corneris (15, 0) and the last pixel position in the 45-degree direction to aleft bottom corner is (0, 15). With respect to the boundary lineconnecting the two pixel positions, partial blocks 1-10 located in aleft top region may be determined as partial blocks to beencoded/decoded, and partial blocks located in a right bottom region maybe determined as partial blocks not to be encoded/decoded. Here, in caseof partial blocks including the boundary line, only the coefficients inthe left top region with respect to the boundary line may be included inthe partial blocks, and the coefficients in the right bottom region maybe excluded from the partial block. The shape of partial block in theleft top region may be determined as a quadrangle (partial blocks 1-5,8) and/or a triangle (partial blocks 6, 7, 9, 10).

FIG. 18 is a diagram illustrating a method of partitioning a transformblock based on DC/AC component attribute in a frequency domain as anembodiment to which the present invention is applied.

In a frequency domain, a partitioning shape of a transform block may bedetermined in consideration of an attribute of DC/AC component includedin the transform block. The attribute may refer to a component position,a degree of distribution, a degree of concentration, strength andweakness, or the like, and the attribute may be determined depending ona transform method (e.g., DCT, DST, etc.) of the transform block.

In a transform block, a region where the AC component is most weaklyconcentrated may be partitioned into a partial block larger in size thanthe remaining region. For example, in a transform block 1801 of 16×16size, the AC component may be located mostly in partial blocks “5” to“13”. Here, a partial block of 8×8 size may be allocated only to thepartial block 13 in which the AC component is most weakly concentrated,and a partial block of 4×4 size may be allocated to the remainingregion.

Alternatively, in a transform block, a region where the AC component ismost weakly concentrated may be partitioned into a partial block smallerin size than the remaining region. For example, in a transform block1802 of 16×16 size, the AC component may be located mostly in partialblocks “2” to “7”. Here, a partial block of 4×4 size may be allocatedonly to the partial blocks “4” to “7” in which the AC component is mostweakly concentrated, and a partial block of 8×8 size may be allocated tothe remaining region.

Alternatively, in a transform block, a region where the DC component ismost strongly concentrated may be partitioned into a partial blocksmaller in size than the remaining region. For example, in a transformblock 1803 of 16×16 size, the DC component may be located mostly inpartial blocks “1” to “4”. Here, a partial block of 4×4 size may beallocated only to the partial blocks “1” to “4” in which the DCcomponent is most strongly concentrated, and a partial block of 8×8 sizemay be allocated to the remaining region.

Alternatively, in a transform block, a region where the DC component ismost strongly concentrated may be partitioned into a partial blocklarger in size than the remaining region. For example, in a transformblock 1804 of 16×16 size, the DC component may be located mostly inpartial block “1”. Here, a partial block of 8×8 size may be allocatedonly to the partial blocks “1” in which the DC component is moststrongly concentrated, and a partial block of 4×4 size may be allocatedto the remaining region.

In the above-described embodiment, the DC/AC component region in thetransform block is assumed based on the quadrisected transform block.However, the present invention is not limited thereto, and thesame/similar may be applied to a transform block of N (N≥≥1) equallypartitioned or 2 to the power of N equally partitioned.

Depending on a quantization parameter (QP) of a transform block, all orsome of partial blocks in the transform block may be selectivelyencoded/decoded. For example, when the QP of the transform block islarger than a predetermined QP threshold value, only a partial region inthe transform block may be encoded/decoded. In addition, when the QP ofthe transform block is smaller than a predetermined QP threshold value,all partial blocks in the transform block may be encoded/decoded.

Here, the partial region may be specified by at least one of apredetermined vertical line or a horizontal line. The vertical line maybe located apart from a left boundary of a transform block by a distancea to the left direction, and the horizontal line may be located apartfrom a top boundary of a transform block by a distance b to the bottomdirection. The a and b are natural numbers, and may be the same ordifferent from each other. The partial region may be a region located ona left side with respect to the vertical line and/or on an upper sidewith respect to the horizontal line. The position of thevertical/horizontal line may be predetermined in an imageencoding/decoding device, or may be variably determined in considerationof a size/shape of a transform block. Alternatively, an image encodingdevice may encode information specifying a partial region (e.g.,information for specifying a position of the vertical/horizontal line)and signal the information, and an image decoding device may specify apartial region based on the signaled information. A boundary of thespecified partial region may or may not be in contact with a boundary ofa partial block in a transform block.

For example, the partial region may be one partial block of a regionwhere DC components are concentrated or N partial blocks (N≥≥1) furtherincluding an adjacent partial block. Alternatively, the partial regionmay be specified by a vertical line crossing 1/n point of a top boundaryof a transform block and/or a horizontal line crossing 1/m point of aleft boundary of a transform block. The n and m are natural numbers andmay be the same or different from each other.

The number of OP threshold values may be one, two, or more. A QPthreshold value may be predetermined in an image encoding device. Forexample, the QP threshold value may correspond to a median value of arange of QPs available in an image encoding/decoding device.Alternatively, an image encoding device may determine an optimal QPthreshold value considering encoding efficiency, and may encode the OPthreshold.

Alternatively, depending on a size of a transform block, all or some ofpartial blocks in the transform block may be selectivelyencoded/decoded. For example, when a size of a transform block is equalto or greater than a predetermined threshold size, only a partial regionin the transform block may be encoded/decoded. In addition, when a sizeof a transform block is smaller than a predetermined threshold size, allpartial blocks in a transform block may be encoded/decoded.

Here, the partial region may be specified by at least one of apredetermined vertical line or a horizontal line. The vertical line maybe located apart from a left boundary of a transform block by a distancea to the left direction, and the horizontal line may be located apartfrom a top boundary of a transform block by a distance b to the bottomdirection. The a and b are natural numbers, and may be the same ordifferent from each other. The a may fall within a range of 0 to a widthof a transform block, and the b may fall within a range of 0 to a heightof a transform block. The partial region may be a region located on aleft side with respect to the vertical line and/or on an upper side withrespect to the horizontal line. The position of the vertical/horizontalline may be predetermined in an image encoding/decoding device, or maybe variably determined in consideration of a size/shape of a transformblock. Alternatively, an image encoding device may encode informationspecifying a partial region (e.g., information for specifying a positionof the vertical/horizontal line) and signal the information, and animage decoding device may specify a partial region based on the signaledinformation. A boundary of the specified partial region may or may notbe in contact with a boundary of a partial block in a transform block.

For example, the partial region may be one partial block of a regionwhere DC components are concentrated or N partial blocks (N≥≥1) furtherincluding an adjacent partial block. Alternatively, the partial regionmay be specified by a vertical line crossing 1/n point of a top boundaryof a transform block and/or a horizontal line crossing 1/m point of aleft boundary of a transform block. The n and m are natural numbers andmay be the same or different from each other.

The number of threshold sizes may be one, two, or more. The thresholdsize may be predetermined in an image encoding device. For example, thethreshold size may be represented by c×d, where c and d are 2, 4, 8, 16,32, 64 or more, and c and d may be the same or different. Alternatively,an image encoding device may determine an optimal threshold size inconsideration of encoding efficiency, and encode the threshold size.

Next, a method of encoding/decoding a block using amulti-intra-prediction mode will be described in detail.

An encoding block may be partitioned into at least one prediction block,and each prediction block may be partitioned into at least one partialblock (or a prediction partial block) through an additional partitioningprocedure. Here, each partial block may be encoded using differentintra-prediction modes. That is, an encoding block or a prediction blockmay be partitioned into a plurality of prediction blocks or a pluralityof partial blocks using a multi-intra-prediction mode (or a multi-mode).A prediction block may be partitioned into a plurality of partial blocksaccording to a predetermined pattern. Here, a partitioning shape of aprediction block may be predetermined and used in an image encodingdevice and an image decoding device.

Hereinafter, encoding/decoding of multi-intra-prediction modeinformation will be described in detail with reference to the drawings.

FIG. 19 is a flowchart illustrating a procedure of determining whetherto use a multi-intra-prediction mode in an encoding procedure. In thisembodiment, it is assumed that a current block represents a predictionblock that is encoded in a current intra-prediction mode. In some cases,a current block may be an encoding block, a transform block or a partialblock generated by partitioning a prediction block.

First, an encoding device may search for a point (hereinafter, referredto as an ‘inflection point’) at which a pixel value among adjacentpixels adjacent to the current block changes significantly (S601). Theinflection point may mean a point where the pixel value change betweenan adjacent pixel and a neighboring pixel neighboring the adjacent pixelis equal to or greater than a predetermined threshold value, or a pointwhere the pixel value change between an adjacent pixel and a neighboringpixel neighboring the adjacent pixel is greatest.

FIG. 20 is a diagram for explaining an example of searching for aninflection point. For convenience of explanation, it is assumed that acurrent block is a prediction block of 4×4 size.

An encoding device may calculate a degree of pixel value change(hereinafter, referred to as an ‘inflection value’) for each of adjacentpixels adjacent to a current block. The inflection value may becalculated based on a change amount (or a differential value) between anadjacent pixel adjacent to a current block and a neighboring pixelneighboring the adjacent pixel, or a change amount (or a differentialvalue) between neighboring pixels neighboring the adjacent pixel.

Here, adjacent pixels adjacent to a current block include at least oneof a pixel adjacent to a top boundary of the current block, a pixeladjacent to a left boundary of the current block and a pixel adjacent toa corner (e.g., left top corner, right top corner and left bottomcorner) of the current block. For example, in the example shown in FIG.20, pixels a to k are exemplified as adjacent pixels of the currentblock.

For additional example, an encoding device may calculate an inflectionvalue for the remaining adjacent pixels excluding pixels (e.g., at leastone of a pixel adjacent to left top corner of the current block, a pixeladjacent to left bottom corner of the current block, and a pixeladjacent to right top corner of the current block) adjacent to a cornerof the current block from adjacent pixels adjacent to the current block.Alternatively, the encoding device may calculate an inflection value forthe remaining adjacent pixels excluding the rightmost pixel or thebottommost pixel among the adjacent pixels adjacent to the currentblock. For example, in the example shown in FIG. 20, the encoding devicemay calculate an inflection value for the remaining pixels except for fand k pixels among the adjacent pixels a to k.

The number or range of adjacent pixels may vary depending on a size andshape of the current prediction block. Accordingly, depending on thesize and shape of the current block, the number or range of adjacentpixels subjected to calculating the inflection value may also vary.

Equation 4 shows an example of a calculating method of an inflectionvalue.

$\begin{matrix}{{{IF}\mspace{14mu}( {{{ADJACENT}\mspace{14mu}{PIXEL}}=={{LEFT}\mspace{14mu}{TOP}\mspace{14mu}{ADJACENT}\mspace{14mu}{PIXEL}}} )}{{{INFLECTION}\mspace{14mu}{VALUE}} = {{( {{- 1}*{BOTTOM}\mspace{14mu}{PIXEL}\mspace{14mu}{OF}\mspace{14mu}{CURRENT}\mspace{14mu}{ADJACENT}\mspace{14mu}{PIXEL}} ) + ( {1*{RIGHT}\mspace{14mu}{PIXEL}\mspace{14mu}{OF}\mspace{14mu}{CURRENT}\mspace{14mu}{ADJACENT}\mspace{14mu}{PIXEL}} )}}}{{ELSE}\mspace{14mu}{IF}\mspace{14mu}( {{{ADJACENT}\mspace{14mu}{PIXEL}}=={{LEFT}\mspace{14mu}{ADJACENT}\mspace{14mu}{PIXEL}}} )}{{{INFLECTION}\mspace{14mu}{VALUE}} = {{( {{- 1}*{TOP}\mspace{14mu}{PIXEL}\mspace{14mu}{OF}\mspace{14mu}{CURRENT}\mspace{14mu}{ADJACENT}\mspace{14mu}{PIXEL}} ) + ( {1*{BOTTOM}\mspace{14mu}{PIXEL}\mspace{14mu}{OF}\mspace{14mu}{CURRENT}\mspace{14mu}{ADJACENT}\mspace{14mu}{PIXEL}} )}}}{{ELSE}\mspace{14mu}{IF}\mspace{14mu}( {{{ADJACENT}\mspace{14mu}{PIXEL}}=={{TOP}\mspace{14mu}{ADJACENT}\mspace{14mu}{PIXEL}}} )}{{{INFLECTION}\mspace{14mu}{VALUE}} = {{( {{- 1}*{LEFT}\mspace{14mu}{PIXEL}\mspace{14mu}{OF}\mspace{14mu}{CURRENT}\mspace{14mu}{ADJACENT}\mspace{14mu}{PIXEL}} ) + ( {1*{RIGHT}\mspace{14mu}{PIXEL}\mspace{14mu}{OF}\mspace{14mu}{CURRENT}\mspace{14mu}{ADJACENT}\mspace{14mu}{PIXEL}} )}}}\mspace{20mu}{ELSE}\mspace{20mu}{{{INFLECTION}\mspace{14mu}{VALUE}} = 0}} & \lbrack {{Equation}\mspace{14mu} 4} \rbrack\end{matrix}$

In Equation 4, the current adjacent pixel indicates an adjacent pixelsubjected to calculation of an inflection value among adjacent pixelsadjacent to the current block. The inflection value of the currentadjacent pixel may be calculated as a value obtained by applyingabsolute value to the difference between neighboring adjacent pixelsneighboring the current adjacent pixel. For example, the inflectionvalue of the adjacent pixels (e.g., pixels ‘b to e’ in FIG. 20) adjacentto a top side of the current block may be calculated based on adifference between an adjacent pixel neighboring a left side of theadjacent pixel and an adjacent pixel neighboring a right side of theadjacent pixel. The inflection value of the adjacent pixels (e.g.,pixels ‘g to j’ in FIG. 20) adjacent to a left side of the current blockmay be calculated based on a difference between an adjacent pixelneighboring a top side of the adjacent pixel and an adjacent pixelneighboring a bottom side of the adjacent pixel. The inflection value ofthe adjacent pixel (e.g., pixel ‘a’ in FIG. 20) adjacent to a left topcorner of the current block may be calculated based on a differencebetween an adjacent pixel neighboring a bottom side of the adjacentpixel and an adjacent pixel neighboring a right side of the adjacentpixel.

As described above, some of the adjacent pixels of the current block(e.g., pixels f and k not adjacent to the boundary of the current blockamong the adjacent pixels) may be excluded from the calculation of theinflection value. An inflection value of adjacent pixels that areexcluded from the calculation of the inflection value among adjacentpixels of the current block may be set to a predetermined value (e.g.,0).

When the calculation of the inflection value for the adjacent pixels iscompleted, the encoding device may select an inflection point based onthe calculated inflection value. For example, the encoding device mayset an adjacent pixel having a largest inflection value or an adjacentpixel having a largest inflection value among adjacent pixels having theinflection value equal to or greater than a threshold value as aninflection point. For example, in the example shown in FIG. 20, when theinflection value of the adjacent pixel b is the maximum, the encodingdevice may set the point ‘O’ shown in FIG. 20 as the inflection point.

When there are a plurality of adjacent pixels having the same maximuminflection value, the encoding device may recalculate inflection valuesfor the plurality of adjacent pixels, or based on a predeterminedpriority, one of the adjacent pixels may be selected as an inflectionpoint.

For example, when there are a plurality of adjacent pixels having thesame maximum inflection value, the encoding device may recalculateinflection values of those inflection points, with adjusting the numberor position of adjacent pixels used for recalculating the inflectionvalues. For example, the encoding device may increase the number ofneighboring pixels adjacent to the adjacent pixels in bidirectional (orunidirectional) by one when recalculating the inflection values of theadjacent pixels. Accordingly, when the adjacent pixels having themaximum inflection value are adjacent pixels adjacent to the top side ofthe current block, using two adjacent pixels neighboring the left of theadjacent pixel and two adjacent pixels neighboring the right of theadjacent pixel, the inflection value of the adjacent pixels may berecalculated.

For additional example, when there are a plurality of adjacent pixelshaving the same maximum inflection value, the encoding device may selectan adjacent pixel close to a pixel at a specific position as aninflection point. For example, the encoding device may give a higherpriority to an inflection point closer to a left top adjacent pixel ofthe current block.

For additional example, when there are a plurality of adjacent pixelshaving the same maximum inflection value, the encoding device mayrecalculate inflection values of the inflection points and determines aninflection point based on the recalculated inflection value, and whenthere are a plurality of adjacent pixels having the maximum inflectionvalue even after recalculating the inflection value, the encoding devicemay select an inflection point based on priority.

In the above-described example, it is described that an inflection pointmay be determined based on adjacent pixels adjacent to the current blockand adjacent pixels neighboring the adjacent pixels. In addition to theexample described above, the inflection point may be determined based onencoding parameters of adjacent blocks neighboring the current block.Here, the encoding parameters are parameters used for encoding adjacentblocks, and may include prediction related information such as anintra-prediction mode, a motion vector, and the like. For example, aboundary of an adjacent block may be set as an inflection point in acase where a difference of the intra-prediction modes between adjacentblocks neighboring the current block is equal to or greater than apredetermined threshold value, a difference of motion vectors betweenadjacent blocks neighboring the current block is equal to or greaterthan a predetermined threshold value, or the like. Accordingly, when thedifference of encoding parameters between adjacent blocks is large, itmay be predicted that a sharp change occurs at the boundary of theadjacent block, and thus encoding/decoding efficiency may be improved byusing the boundary of the adjacent block as an inflection point. Thedecoding device may also determine an inflection point using theencoding parameters of the adjacent blocks.

When the inflection point is determined, the encoding device maydetermine a partitioning shape of the current block based on theinflection point (S602).

FIG. 21 is a diagram illustrating a partitioning shape according to ashape of a current block.

In the example shown in FIG. 21, the current block may be partitionedinto two or more partial blocks, according to at least one referenceline. Here, partial blocks generated by partitioning the current blockmay have a triangular or trapezoidal shape as well as a non-squareshape. In FIG. 21, the reference numeral 2101 is an example that thereare 18 partitioning lines (or 18 partitioning shapes) when the currentblock is a square, and the reference numerals 2102 and 2103 in FIG. 21indicate that there are 20 partitioning lines (or 20 partitioningshapes) when the current block is a non-square. However, thepartitioning shape of the current block is not limited to theillustrated example. In addition to what is shown, various shapes ofdiagonal partitioning or bisectional partitioning may be applied.

The encoding device may select a partitioning line having a determinedinflection point as a starting point or a partitioning line having astarting point closest to the determined inflection point, and maypartition the current block according to the selected partitioning line.For example, when the position of the inflection point does not matchwith a left or top starting point of the partitioning line, the encodingdevice may change the position of the inflection point to the startingpoint of the closest partitioning line.

After that, the encoding device may calculate slope information of thepixel adjacent to the inflection point in order to determine in whichshape the current block is partitioned from the inflection point.

For example, FIG. 22 is a diagram for explaining an example ofcalculating slope information of an adjacent pixel. For convenience ofexplanation, it is assumed that the size of the current block is 4×4 andthe inflection point is b1.

The encoding device may calculate the slope information using N pixelsselected based on the inflection point. For example, as in the exampleshown in FIG. 22, the encoding device may configure a 3×3 blockincluding the inflection point b1 and calculate the slope informationbased on the pixels included in the configured 3×3 block.

When the inflection point of the current block is an adjacent pixellocated at a top side of the current block, the inflection point may beincluded in the bottommost row of the 3×3 block. In addition, when theinflection point of the current block is an adjacent pixel located at aleft side of the current block, the inflection point may be included inthe rightmost column of the 3×3 block. That is, when the inflectionpoint of the current block exists at a top side, a 3×3 block may beconfigured mostly with the adjacent pixels of the inflection point andthe pixels located at the top side of the inflection point. In addition,when the inflection point of the current block exists at a left side, a3×3 block may be configured mostly with the adjacent pixels of theinflection point and the pixels located at the left side of theinflection point.

The encoding device may calculate horizontal directional slope andvertical directional slope using adjacent pixels neighboring theinflection point, and based on the horizontal directional slope and thevertical directional slope, may calculate slope information for thecurrent block. For example, Equation 5 shows a series of procedure forcalculating slope information.

$\begin{matrix}{{{f_{x}( {x,y} )} = {{I( {{x + 1},y} )} - {I( {{x - 1},y} )}}},{{f_{y}( {x,y} )} = {{I( {x,{y + 1}} )} = {I( {x,{y - 1}} )}}},{\theta_{({x,y})} = {\tan^{- 1}{\frac{f_{y}( {x,y} )}{f_{x}( {x,y} )}.}}}} & \lbrack {{Equation}\mspace{14mu} 5} \rbrack\end{matrix}$

In Equation (5), f_(x)(x, y) represents a degree of slope in ahorizontal direction, and f_(y)(x, y) represents a degree of slope in avertical direction. A slope of a current block may be obtained byapplying arctangent for a slope value in the vertical direction to aslope value in the horizontal direction. A contour direction of thecurrent block may be identified through the slope value of the currentblock.

In the above example, the slope value may be calculated based onadjacent pixels adjacent to the current block and adjacent pixelsneighboring the adjacent pixels. For additional example, a slope of thecurrent block may be determined based on the encoding parameters ofadjacent blocks neighboring the current block. For example, the slopevalue may be determined based on intra-prediction modes (orintra-prediction mode angles) of adjacent blocks neighboring theinflection point, motion vectors of adjacent blocks neighboring theinflection point, or the like. When the inflection point is located at aboundary between adjacent blocks, the encoding device may encode indexinformation indicating encoding parameters of which adjacent block amongadjacent blocks located at the inflection point is used for determiningthe slope value. Here, the index information may be informationindicating one of the adjacent blocks.

When a slope of a current block is calculated, an encoding device maydetermine an optimal partitioning shape for the current block inconsideration of a position of an inflection point and a degree ofslope. Here, the optimal partitioning shape may be one using apartitioning line having a slope angle identical to the slope angle ofthe current block among partitioning lines having a start point of theinflection point of the current block, or a partitioning line having aslope angle most similar to the slope angle of the current block (i.e.,a partitioning line having a slope angle with a minimum difference fromthe slope angle of the current block). Here, when there are a pluralityof partitioning shapes having the slope angle most similar to the slopeangle of the current block, the encoding device may select apartitioning shape having a higher priority according to a predeterminedpriority.

An encoding device may encode information for determining a partitioningshape of a current block, and may transmit the encoded information to adecoding device through a bitstream. The information for determining thepartitioning shape of the current block may be encoded through aprediction block unit or an upper header. Here, the upper header maymean an encoding block layer, a slice layer, a picture layer, a sequencelayer, a video layer, and the like.

The information for determining the partitioning shape of the currentblock may include at least one of an index for identifying apartitioning shape of a current block, a position of an inflection pointor slope information. For example, the position of the inflection pointmay be encoded through a prediction block unit or an upper header andtransmitted to a decoding device.

For additional example, a decoding device may determine a partitioningshape of a current block in the same manner as the encoding device. Forexample, the decoding device may derive an inflection point based on apixel value change amount between adjacent blocks, calculate slopeinformation using N pixels around the derived inflection point, and thendetermine one of a predetermined partitioning patterns as a partitioningshape of the current block.

Here, the encoding device may encode information on whether to use themulti-intra-prediction mode (i.e., whether to perform intra-predictionby partitioning one current block into a plurality of partial blocks),and transmit the encoded information through a bitstream. The decodingdevice may encode the information and partition the current block into aplurality of partial blocks only when the information indicates thatintra-prediction is to be performed by partitioning the current blockinto a plurality of partial blocks.

When a partitioning shape for a current block is determined, an encodingdevice may determine an intra-prediction mode for each partial blockincluded in the current block (S603). Here, the encoding device mayallocate different intra-prediction modes to each partial block.

Based on a Rate Distortion-Cost (RD-cost) value calculated by performingRate Distortion Optimization (RDO) for each intra-prediction mode for apartial block, an encoding device may determine an intra-prediction modefor each partial block included in a current block. For example, theencoding device may determine the intra-prediction mode in which theRD-cost value is minimum for each partial block included in the currentblock, as the intra-prediction mode of each partial block.

In performing RDO, the encoding device may calculate RD-cost value forall available intra-prediction modes, or may calculate RD-cost value fora part of intra-prediction modes. The part of intra-prediction modes maybe set and used the same in the image encoding device and the imagedecoding device. Alternatively, the part of intra-prediction modes mayinclude only an intra-prediction mode using only reference pixelsadjacent to the current block.

For additional example, the part of intra-prediction modes may includeat least one of an intra-prediction mode of an adjacent blockneighboring to the current block and a predetermined additionalintra-prediction mode. For example, when the intra-prediction mode ofthe adjacent block is a non-directional mode. RDO may be performed fromcandidates of all the non-directional modes, some directional predictionmodes having high selection frequencies (e.g., a vertical directionalprediction mode, a horizontal directional prediction mode, etc.), andthe like. Alternatively, when the intra-prediction mode of the adjacentblock is a directional mode, RDO may be performed from candidates of allthe non-directional modes, an intra-prediction mode of the adjacentblock, an intra-prediction mode of the adjacent block, anintra-prediction mode having a direction similar to the intra-predictionmode of the adjacent block (e.g., an intra-prediction mode in which thedifference from an intra-prediction mode of the adjacent block is equalto or less than a threshold value), and the like.

An encoding device may perform intra-prediction on a current block usinga selected intra-prediction mode. Here, when the current block ispartitioned into partial blocks by diagonal lines, the partitioninglines may not match to a pixel boundary, and overlapping pixels (i.e.,overlapping region) between partial blocks may appear.

For example, FIG. 23 is a diagram illustrating an example in which anoverlapping region is generated according to a partitioning shape of acurrent block.

In the case of the blocks corresponding to the reference numerals 2301and 2302 shown in FIG. 23, since the partitioning line matches to thepixel boundaries, overlapping regions between partial blocks do notoccur. However, in the case of the blocks corresponding to the referencenumerals 2303 to 2305, since there are portions where the partitioningline does not match to the pixel boundaries (i.e., portions where thepartitioning line passes through a pixel), it may be considered thatoverlapping pixels (i.e., overlapping regions) between partial blocksexist.

As such, when there are overlapping regions between partial blocks, aprediction value of a pixel included in an overlapping region may beobtained by an average of prediction values generated as theintra-prediction results of the partial blocks including the overlappingregion, linear interpolation of the prediction values, or the like. Forexample, assuming that the current block is partitioned into a firstpartial block and a second partial block, a prediction value of a pixelcommonly included in the first partial block and the second partialblock may be determined as an average value of a first prediction valuecalculated using an intra-prediction mode of the first partial block anda second prediction value calculated using an intra-prediction mode ofthe second partial block, or a value of linear interpolation of thefirst prediction value and the second prediction value.

For additional example, a prediction value of a pixel included in anoverlapping region may be generated using an intra-prediction mode ofany one of partial blocks including the overlapping region. Here, whichblock among the partial blocks is used may be determined based on apredetermined priority between partial blocks, a predetermined prioritybetween intra-prediction modes, a position of a pixel included in anoverlapping region, or the like. For example, a prediction value of apixel included in an overlapping region may be generated using anintra-prediction mode having a higher predetermined priority amongintra-prediction modes of partial blocks including the overlappingregion.

Next, encoding of an intra-prediction mode for each partial block in anencoding device will be described in detail.

FIG. 24 is a flowchart illustrating a procedure of encoding anintra-prediction mode of a partial block. For convenience ofexplanation, the intra-prediction modes of the partial blocks areclassified into a primary prediction mode and a secondary predictionmode. Herein, the primary prediction mode may indicate anintra-prediction mode of one of the partial blocks, and the secondaryprediction mode may indicate an intra-prediction mode of another partialblock of the partial blocks. Alternatively, the primary prediction modeand the secondary prediction mode may be determined according to apriority for the intra-prediction modes, a size of a partial block, aposition of a partial block, a size of a partial block, or the like. Thesecondary prediction mode may be determined to be an intra-predictionmode different from the primary prediction mode.

First, an encoding device may encode operation information formulti-intra-prediction (S1101). Here, the multi-mode operationinformation indicates whether using a single intra-prediction mode forthe current block is optimal or using a plurality of intra-predictionmodes is optimal.

When the multi-intra-prediction mode is true (S1102), the encodingdevice may encode an intra-prediction mode determined as a primaryprediction mode (S1103), and then encode an intra prediction modedetermined as a secondary prediction mode (S1104). The primaryprediction mode may be encoded through an encoding procedure using MPM(Most Probable Mode) candidates, or may be encoded without using MPMcandidates. The secondary prediction mode may be encoded through anencoding procedure using MPM candidates, or may be encoded without usingMPM candidates.

The encoding device may encode a differential value between the primaryprediction mode and the secondary prediction mode. For example, theencoding device may encode the primary prediction mode using MPMcandidates, and may encode the differential value between the primaryprediction mode and the secondary prediction mode. In this case, adecoding device may derive the primary prediction mode using MPMcandidates, and obtain the secondary prediction mode through thedifferential value between the primary prediction mode and the secondaryprediction mode.

When the multi-intra-prediction mode is false (S1102), the encodingdevice may encode a single intra-prediction mode for the current block(S1105). For example, the encoding device may encode an intra-predictionmode for the current block using MPM candidates.

Referring to FIG. 25, encoding of an intra-prediction mode for a currentblock using MPM candidates will be described in detail

FIG. 25 is a flowchart illustrating a method of encoding anintra-prediction mode using MPM candidates. In this embodiment, theintra-prediction mode of the current block may mean one of the primaryprediction mode, the secondary prediction mode or the single predictionmode.

Referring to FIG. 25, first, an encoding device may determine MPMcandidates for a current block (S1201). The encoding device maydetermine the MPM candidates of the current block based onintra-prediction modes of neighboring blocks neighboring the currentblock.

For example, FIG. 26 is a diagram illustrating determination of an MPMcandidate of a current block. In FIG. 26, L may indicate anintra-prediction mode with a highest frequency of use amongintra-prediction modes of left neighboring blocks adjacent to a leftside of the current block, A may indicate an intra-prediction mode witha highest frequency of use among intra-prediction modes of topneighboring blocks adjacent to a top side of the current block.Alternatively, L may indicate an intra-prediction mode of a leftneighboring block at a specific position, and A may indicate anintra-prediction mode of a top neighboring block at a specific position.

In FIG. 26, it is shown that the MPM candidates of the current block arethree, and the three MPM candidates may include at least one of L, A,the intra-prediction modes (i.e., L−1 and L+1) having similar directionto L, non-directional mode (Planar, DC) and a predetermined directionalmode (vertical mode). However, the present invention is not limited tothe illustrated example, and MPM candidates of the current block may begenerated by a method different from that shown. For example, MPMcandidates of the current block may include more than three.

When neighboring blocks neighboring the current block are coded inmulti-intra-prediction mode, the MPM candidates of the current block maybe determined by considering all of the multi-intra-prediction modes ofthe neighboring blocks, or may be determined by considering only one ofthe multi-intra-prediction modes of the neighboring blocks. For example,the MPM candidates of the current block may be determined consideringthe primary prediction mode among the multi-intra-prediction modes ofthe neighboring blocks.

Alternatively, the MPM candidates for a primary prediction mode of thecurrent block may be determined using a primary prediction mode of theneighboring block, and the MPM candidates for a secondary predictionmode of the current block may be determined using a secondary predictionmode of the neighboring block.

The encoding device may determine whether there is an MPM candidateidentical to an intra-prediction mode of the current block, and mayencode operation information according to the determination result(S1202). Here, the operation information may be a 1-bit flag (e.g., anMPM flag). For example, when there is an MPM candidate identical to theintra-prediction mode of the current block, the encoding device mayencode the MPM flag to ‘true’. When there is no MPM candidate identicalto the intra-prediction mode of the current block, the encoding devicemay encode the MPM flag to ‘false’.

When there is an MPM candidate identical to the intra-prediction mode ofthe current block (S1203), the encoding device may encode indexinformation specifying the MPM candidate identical to theintra-prediction mode of the current block (S1204).

When there is no MPM candidate identical to the intra-prediction mode ofthe current block (S1203), the encoding device may encode a residualmode indicating an optimal intra-prediction mode for the current blockamong the residual intra-prediction modes excluding the MPM candidate(S1205). Specifically, the encoding device may encode the residual modeby allocating as many bits as the number of residual intra-predictionmodes obtained by subtracting the number of MPM candidates from a totalintra-prediction modes (or intra-prediction modes available for thecurrent block).

The secondary prediction mode is set to a value different from theprimary prediction mode, and a residual mode for the secondaryprediction mode may be encoded based on the residual intra-predictionmodes excluding the MPM candidates and the primary prediction mode.

Next, a method for decoding an optimal intra-prediction mode in adecoding device will be described.

FIG. 27 is a flowchart illustrating a method of decoding anintra-prediction mode of a current block.

Referring to FIG. 27, first, the decoding device may decode multi-modeoperation information from a bitstream (S1401). Here, the multi-modeoperation information may indicate whether the current block is encodedusing the multi-intra-prediction mode.

When it is determined that the current block is encoded using themulti-intra-prediction mode (S1402), the decoding device may partitionthe current block into a plurality of partial blocks. Here, the decodingdevice may partition the current block based on block partitioningpattern information signaled from the encoding device, or may calculatean inflection point and slope, select a partitioning patterncorresponding to the calculated inflection point and slope, and thenpartition the current block.

When the current block is partitioned into a plurality of partialblocks, the decoding device may decode a primary prediction mode for thecurrent block (S1403), and then decode a secondary prediction mode(S1404). As described in the encoding procedure, the primary predictionmode or the secondary prediction mode may be decoded using MPMcandidates, or may be decoded without using MPM candidates.Alternatively, after decoding the primary prediction mode, the secondaryprediction mode may be obtained based on a differential value betweenthe primary prediction mode and the secondary prediction mode.

When it is determined that the current block is encoded without usingmulti-intra-prediction mode, the decoding device may decode a singleintra-prediction mode for the current block (S1405). Here, the singleintra-prediction mode for the current block may be decoded using MPMcandidates.

FIG. 28 is a flowchart illustrating a method of decoding anintra-prediction mode using MPM candidates. In this embodiment, theintra-prediction mode of the current block may mean one of the primaryprediction mode, the secondary prediction mode or the single predictionmode.

First, a decoding device may determine MPM candidates for a currentblock (S1501). The decoding device may determine the MPM candidates ofthe current block based on intra-prediction modes of neighboring blocksneighboring the current block. The generation of the MPM candidates ofthe current block has been described in detail with reference to FIG.26, and a detailed description thereof will be omitted.

Thereafter, the decoding device may decode information indicatingwhether there is an MPM candidate identical to the intra-prediction modeof the current block (S1502). The information may be a 1-bit flag, butis not limited thereto.

When it is determined that there is an MPM candidate identical to theintra-prediction mode of the current block (S1503), the decoding devicemay decode information (e.g., MPM index information) specifying the MPMcandidate identical to the intra-prediction mode of the current block(S1504). In this case, the intra-prediction mode of the current blockmay be determined as the intra prediction mode specified by the MPMindex information.

In addition, when it is determined that there is no MPM candidateidentical to the intra-prediction mode of the current block (S1503), thedecoding device may decode residual mode information (S1505), and basedon the decoded residual mode information, determine the intra-predictionmode for the current block. Here, the residual mode information may beencoded by excluding MPM candidates from the intra-prediction modesavailable for the current block.

Although the exemplary methods of this disclosure are represented by aseries of steps for clarity of explanation, they are not intended tolimit the order in which the steps are performed, and if necessary, eachstep may be performed simultaneously or in a different order. In orderto implement the method according to the present disclosure, it ispossible to include other steps to the illustrative steps additionally,exclude some steps and include remaining steps, or exclude some stepsand include additional steps.

The various embodiments of the disclosure are not intended to beexhaustive of all possible combination, but rather to illustraterepresentative aspects of the disclosure, and the features described inthe various embodiments may be applied independently or in a combinationof two or more.

In addition, various embodiments of the present disclosure may beimplemented by hardware, firmware, software, or a combination thereof. Acase of hardware implementation may be performed by one or moreapplication specific integrated circuits (ASICs), digital signalprocessors (DSPs), digital signal processing devices (DSPDs),programmable logic devices (PLDs), field programmable gate arrays(FPGAs), a general processor, a controller, a microcontroller, amicroprocessor, and the like.

The scope of the present disclosure is to encompass software ormachine-executable instructions (e.g., operating system, applications,firmware, instructions, and the like) by which operations according tomethod of various embodiments are executed on a device or a computer,and non-transitory computer-readable media executable on the device orthe computer, on which such software or instructions are stored.

INDUSTRIAL APPLICABILITY

The present invention may be applied to encoding/decoding image.

1. A method of decoding an image signal, comprising: receiving abitstream including a coded picture of the image signal; dividing atransform block in the coded picture into a plurality of partial blocks;decoding a coefficient of the transform block in units of the partialblocks; and reconstructing the transform block using the decodedcoefficient, wherein decoding the coefficient of the transform blockcomprises: decoding a plurality of flags for a current coefficient,wherein the plurality of flags include a first flag and a second flag,wherein the first flag indicates whether an absolute value of thecurrent coefficient is greater than a first value, wherein the secondflag indicates whether the absolute value of the current coefficient isgreater than a second value, and wherein the first value is equal to 1and the second value is greater than or equal to
 3. 2. The method ofclaim 1, wherein the plurality of flags further include a third flag,wherein the third flag indicates whether the absolute value of thecurrent coefficient is greater than a third value, and wherein the thirdvalue is a natural number greater than the second value.
 3. The methodof claim 1, wherein the partial block is representative of a non-squareblock having a size of N×M.
 4. The method of claim 3, wherein whether ornot the partial block is the non-square block is determined based onboth a size of the transform block and a shape of the transform block.5. The method of claim 4, wherein a decoding order of the partial blocksbelonging to the transform block is determined based on a pre-determinedscan type, and wherein the scan type is determined based on both apartitioning type of a coding block including the transform block and asize of the transform block.
 6. A method of encoding an image signal,comprising: receiving a picture of the image signal; generating residualdata of a transform block in the picture, the residual data being adifference between an original block of a coding block and a predictionblock of the coding block; dividing the transform block into a pluralityof partial blocks; and encoding a coefficient of the transform block inunits of the partial blocks, wherein encoding the coefficient of thetransform block comprises: encoding a plurality of flags for a currentcoefficient, wherein the plurality of flags include a first flag and asecond flag, wherein the first flag indicates whether an absolute valueof the current coefficient is greater than a first value, wherein thesecond flag indicates whether the absolute value of the currentcoefficient is greater than a second value, and wherein the first valueis equal to 1 and the second value is greater than or equal to
 3. 7. Anon-transitory computer-readable medium for storing data associated withan image signal, comprising: a data stream encoded by an encodingmethod, wherein the encoding method comprises: receiving a picture ofthe image signal; generating residual data of a transform block in thepicture, the residual data being a difference between an original blockof a coding block and a prediction block of the coding block; dividingthe transform block into a plurality of partial blocks; and encoding acoefficient of the transform block in units of the partial blocks,wherein encoding the coefficient of the transform block comprises:encoding a plurality of flags for a current coefficient, wherein theplurality of flags include a first flag and a second flag, wherein thefirst flag indicates whether an absolute value of the currentcoefficient is greater than a first value, wherein the second flagindicates whether the absolute value of the current coefficient isgreater than a second value, wherein the first value is equal to 1 andthe second value is greater than or equal to 3.